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

Script only works on studio?

Asked by 9 years ago
script.Parent.MouseButton1Click:connect(function()
    if game.Players.LocalPlayer.leaderstats.Money.Value == 650 or game.Players.LocalPlayer.leaderstats.Money.Value > 650 then
        if game.Players.LocalPlayer.Backpack:FindFirstChild("Heal Spell") == nil then

        game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value - 650
        local c = game.ServerStorage["Heal Spell"]:Clone()
        c.Parent = game.Players.LocalPlayer.Backpack
        end
        end
end)

This script is supposed to clone you a heal spell if you have enough money, and if you don't already own it. The problem is it only works in studio. This is a localscript inside a Textbutton.

0
Try putting this in replicated storage, then cloning it from there. Operation_Meme 890 — 9y

2 answers

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

LocalScripts don't have access to ServerStorage -- that's storage for the server. Use ReplicatedStorage for things that clients need access to.

I would recommend storing game.Players.LocalPlayer as a variable, since you use it so many times!


Also, remember that changing leaderstats from a LocalScript won't completely work with FilteringEnabled.

Ad
Log in to vote
0
Answered by 9 years ago

In tandem with what BlueTaslem said, you can't modify objects in ServerStorage from the client. You can try using remote events / functions to modify / access objects stored on the server.

Answer this question