I made this script, and it only runs in studio, i have asked this question several times and i got nothing much but this line of code that someone told me to put on the top of every local script.
--This is the code i got told to put on top of a local script repeat wait() until game.Players.LocalPlayer.Character
So i did put the code on top of the local script and it didnt work, but only on studio.
repeat wait() until game.Players.LocalPlayer.Character Player = game.Players.LocalPlayer Cube = script.Parent local Workspace = game.Workspace mouse = Player:GetMouse() local SwordFold = game.ServerStorage.Sword local Sword = { "Sword" } function Click() while true do for i,v in pairs(SwordFold:GetChildren())do if v.Name == Sword[math.random(1, #Sword)] then wait() v.Enabled = true local Gear = v:Clone() Gear.Parent = Player.Backpack Sound:Play() print(Player.Name,"Got", v.Name.."!") wait() script.Parent:Destroy() end end end end Cube.Activated:connect(Click) Cube.Equipped:connect(onEquipped)
ServerStorage doesn't exist in servers, it is a place where you can store stuff while you work in studio. Put the sword in ReplicatedStorage and
Try this:
repeat wait() until game.Players.LocalPlayer.Character Player = game.Players.LocalPlayer Cube = script.Parent local Workspace = game.Workspace mouse = Player:GetMouse() local SwordFold = game.ReplicatedStorage.Sword local Sword = { "Sword" } function Click() while true do for i,v in pairs(SwordFold:GetChildren())do if v.Name == Sword[math.random(1, #Sword)] then wait() v.Enabled = true local Gear = v:Clone() Gear.Parent = Player.Backpack Sound:Play() print(Player.Name,"Got", v.Name.."!") wait() script.Parent:Destroy() end end end end Cube.Activated:connect(Click) Cube.Equipped:connect(onEquipped)