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

Buying Something from GUI Not working on servers?

Asked by 8 years ago

So I made a shop using a GUI. This works when I play in edit mode but when I play on an actual server it doesn't put the Cheezburger into my inventory. I've tried changing the Variable Tool to game.ServerStorage:WaitForChild('Cheezburger') but it didn't work. Any suggestions would be awesome. This is in a local script inside a image button.

local Player = game.Players.LocalPlayer
local Points = Player:WaitForChild('leaderstats').Points
local Tool = game.ServerStorage:FindFirstChild('Cheezburger')
script.Parent.MouseButton1Down:connect(function()
    if Points.Value >= 45 and not Player.Backpack:FindFirstChild('Cheezburger') or Player.Character:FindFirstChild('Cheezburger') then
        local NewTool = Tool:Clone()
        NewTool.Parent = Player.StarterGear
        local NewTool = Tool:Clone()
        NewTool.Parent = Player.Backpack
    end
end)

1 answer

Log in to vote
2
Answered by 8 years ago

LocalScripts can't see things in ServerStorage

Consider moving it to ReplicatedStorage, or even better consider moving your logic to the server and using a RemoteEvent to tell the server to do it.

0
Moving the Tool to replicated storage fixed the problem. Thanks Elunate! User#11440 120 — 8y
Ad

Answer this question