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)

3 comments
ServerStorage does exist in servers, it's main purpose is to replace the need of Lighting to store objects.
Eh, I just recommend not using it.
Only Server scripts can access ServerStorage, and it can be used as a secure storage for your models, because client can't access it