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

How do I fix this tool cloning localscript?

Asked by
itsJooJoo 195
8 years ago

So I'm making a TextButton, and inside it I added a LocalScript that when the button is clicked, I want it to give a player the item "Latte". It works in Roblox Studio, but not in the actual game! Here it is:

1local player = game.Players.LocalPlayer
2 
3function onClicked()
4    game.ServerStorage.Latte:clone().Parent = player.Backpack
5end
6 
7script.Parent.MouseButton1Down:connect(onClicked)

Does anybody know what's wrong with my script? If so, please help!

2 answers

Log in to vote
0
Answered by 8 years ago

It's probably because the Tool is in the ServerStorage, meaning it is accessible only from Server Scripts, not Local Scripts. Try moving the "Latte" to ReplicatedStorage, it is used for both Server Scripts and Local Scripts.

1local player = game.Players.LocalPlayer
2 
3function onClicked()
4    game.ReplicatedStorage.Latte:clone().Parent = player.Backpack
5end
6 
7script.Parent.MouseButton1Down:connect(onClicked)

Hope it helps! ;)

0
OMIGOSH THANK YOU! I just realized anything with "Server" in it should probably be avoided by client-sided things :P itsJooJoo 195 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
1local player = game.Players.LocalPlayer
2local serverstorage = game:GetService("ServerStorage")
3 
4function onClicked()
5    serverstorage.Latte:Clone().Parent = player.Backpack
6end
7 
8script.Parent.MouseButton1Down:connect(onClicked)

idk but maybe this will work?

0
Sorry, that didn't work ;( itsJooJoo 195 — 8y

Answer this question