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

For some reason this script won't work on the actual game but works on Play Solo on Studio??

I've trying to get this figured out for weeks but i can't figure it out, Is it an error or a bug??? Can someone please help me?

function onClicked()
--- anything you need will be inside here to happen.
local Shop = game.ServerStorage.Shop:Clone()
Shop.Parent = game.Players.LocalPlayer.PlayerGui
end


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

If someone can help me that would be appreciated, Thanks!

2 comments

0

Is your game filteringenabled?

0

@Mowblow No

1 answer

  1. If this is in a Script, it isn't working because you cannot index LocalPlayer in a Script.

ClickDetector's have a built in argument that is the clicker.

  1. If this is in a LocalScript, it isn't working because ClickDetector's do not work in LocalScripts.

2 comments

0

So then how would i get the player that clicked in a script?

0

The MouseClick event of a ClickDetector automatically returns a value which contains the player who clicked it. Therefore you could add a variable as an argument for the function onClicked. e.g.: function onClicked(player)

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