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

Only works in studio?

Asked by 8 years ago

I made this long script, and it only works in studio....

Player = game.Players.LocalPlayer
Cube = script.Parent
local Workspace = game.Workspace
mouse = Player:GetMouse()
function onEquipped()
Cube.Handle.Equipped:Play() 
end

local GearFolder = game.ServerStorage.SwordsFolder


local MovementGearNames = {
"BlackAndWhiteWingedSword",
"BombosSurvivalKnife",



}


function Click()
while true do
for i,v in pairs(GearFolder:GetChildren())do
if v.Name == MovementGearNames[math.random(1, #MovementGearNames)] then
wait(0.01)
v.Enabled = true
local Sound = Instance.new("Sound",script.Parent.Handle)
Sound.SoundId = "rbxassetid://163362522"
Sound.Volume = 1
Sound.Pitch = 1
Sound.Looped = false
Sound.Name = "GearSound"
local Gear = v:Clone()
Gear.Parent = Player.Backpack
Sound:Play()
print(Player.Name,"Got", v.Name.."!")
wait(0.01)
script.Parent:Destroy()

end
end
end







end




Cube.Activated:connect(Click)
Cube.Equipped:connect(onEquipped)

3 answers

Log in to vote
1
Answered by 8 years ago

Problem

The only problem I can see is that since it works in studio and not in server it should be a latency problem, this happens because in studio everything is pretty much local so you don't have to wait for a server to create stuff so your local scripts run instantly. In server this doesn't happen as when a local scripts cause upons something in player or character that is server-sided then the local script is "local" which makes it run faster then the server can respond.

Solution

repeat wait() until game.Players.LocalPlayer.Character--To the top of every local script
0
Well i did put the code that you said on top of the local script, but it didnt work. UltraUnitMode 419 — 8y
Ad
Log in to vote
0
Answered by
Kenet1c 15
8 years ago
repeat wait() until game.Players.LocalPlayer.Character
Log in to vote
0
Answered by
Hexcede 52
8 years ago

I was experiencing this problem too. I was wondering what was going on and I will edit in a fix when I find one! Also in online mode do F9 or fn+F9 if F9 colored the same as the fn key and it will show the output. That might help you.

Answer this question