Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago

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!

0
Is your game filteringenabled? Mowblow 117 — 7y
0
@Mowblow No DeveloPatter 23 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago
  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.
0
So then how would i get the player that clicked in a script? DeveloPatter 23 — 7y
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) Palhairfreak 71 — 7y
Ad

Answer this question