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

Script only works inside ROBLOX Studio but not in online?

Asked by 9 years ago

I recently made a script where when you click on a gun it gets duplicated into your backpack. This is the script i made.

function onClicked()
    game.Lighting["Remington 870"]:Clone().Parent = game.Players.LocalPlayer.Backpack
end

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



But the problem is it works perfectly fine in roblox studio, but when i save and go online it doesn't work. Can someone help me or explain to me why this is happening? Thank you :)

1 answer

Log in to vote
1
Answered by 9 years ago
game.Players.LocalPlayer

That can only be accessed from a LocalScript. Assuming you aren't using FilteringEnabled, try this in a normal script (still inside the ClickDetector):

function onClicked(Clicker) 
    game.Lighting["Remington 870"]:Clone().Parent = Clicker.Backpack 
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
0
I put that code inside of a normal script but nothing happened though? purplemetro3421 5 — 9y
0
Try putting the script in ServerScriptService. Also, I recommend putting the shotgun and other stuff that you want to store in ReplicatedStorage. funyun 958 — 9y
0
Still not working purplemetro3421 5 — 9y
Ad

Answer this question