To get started, open a baseplate from ROBLOX, and add a model
(by clicking on the plus that appears when you hover over the workspace.)
Now Inside that, add:
This will be the code you should add.
local function onClick(player)
if script.Parent.User.Value == '_' then
script.Parent.User.Value == player.Name
script.Parent.ClickDetector:Destroy()
end
end
script.Parent.ClickDetector.MouseClick:Connect(onClick)
To test if this works, walk up to the base, and click it. If the following happens, its working.
maxium77
.Let us have a look at the code a line at a time.
local function onClick(player)
This is making a function, using the variable player. Player is the person
who clicked the part.if script.Parent.User.Value == '_' then
Remember the string value you made earlier? this is checking if it is still
'_'script.Parent.User.Value == player.Name
This is setting the string value to the player's name,
as the player is who clicked the part.script.Parent.ClickDetector:Destroy
This is destroying the ClickDetector. What else would it do?end end
These ends mean the end to the function and the if statement started
earlier.script.Parent.ClickDetector.MouseClick:Connect(onClick)
This is now letting the computer make the connection that is:
"If this part is clicked, do the onClick function."