Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make an OnClicked function local?

Hello, right now I am trying to make a wall that will turn CanCollide to False for the local player.

Right now the code is functional for a regular Script but not a Local Script.

I can give you my code anyways since it might be needed.

function onClicked()

game.Workspace.Wall1.CanCollide = false

end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

✓ Accepted answer

To achieve this effect with a server script, you must use RemoteEvents and two scripts the script in the click block (server) should look like this:

function onClicked(plr)
print(plr.Name)
game.ReplicatedStorage.collision:FireClient(plr, workspace.Wall1)

end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

A remote event should be placed in replicated storage ( i name it "collision" )

and the local script should be placed in startercharacterscripts, with the following code.

game.ReplicatedStorage.collision.OnClientEvent:Connect(function(part)
	part.CanCollide = false
end)

the local script can be sent for by any server script, to change the collision of any brick.

Hope this was helpful :)

This discussion is preserved as it was. New answers, comments, and votes are closed.