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

Why is this Script does Not Give the Player a Tool?

Asked by 6 years ago

I'm trying to make a crate system, I did all the things but it doesn't give the player the tool. I'm using the right parents and all of the other things. This is the script:

local SS = game:GetService("ServerStorage")
local Items = {SS.DefaultSword, SS.Sword}

script.Parent.MouseButton1Click:connect(function()
    local item = Items[math.random(1, #Items)]

    item:Clone().Parent = game.Players.LocalPlayer.Backpack
end)

Thanks, MajinBluee

0
You cannot access ServerStorage from a localscript Amiaa16 3227 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Hello there. The reason it doesn't work is because you cannot access the ServerStorage in local scripts and cloning will not replicate on local scripts. I highly suggest you use a remote event to fire server when the button is clicked, and let the cloning take place on the server.. I will not be providing scripts as I do not wish to make free stuff for you but I am sure this will help. https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events If this helped, please accept answer and if there are anymore, report any more issues in the comments. Accepting answer gives us both rep and marks the question answered.. Thanks!

0
Thanks Bro! MajinBluee 80 — 6y
0
Anytime! DaWarTekWizard 169 — 6y
Ad

Answer this question