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:
local player = game.Players.LocalPlayer function onClicked() game.ServerStorage.Latte:clone().Parent = player.Backpack end script.Parent.MouseButton1Down:connect(onClicked)
Does anybody know what's wrong with my script? If so, please help!
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.
local player = game.Players.LocalPlayer function onClicked() game.ReplicatedStorage.Latte:clone().Parent = player.Backpack end script.Parent.MouseButton1Down:connect(onClicked)
Hope it helps! ;)
local player = game.Players.LocalPlayer local serverstorage = game:GetService("ServerStorage") function onClicked() serverstorage.Latte:Clone().Parent = player.Backpack end script.Parent.MouseButton1Down:connect(onClicked)
idk but maybe this will work?