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

how do you make a loop that no matter what happens it doesnt change?

Asked by 9 years ago

im trying to implement a character creator system but when i try to set the walkspeed to 0 and jump to false i move my cam and the script auto stops looping


Player = game.Players.LocalPlayer character = Player.Character hum = character:FindFirstChild("Humanoid") while true do hum.WalkSpeed = 0 hum.Jump = false wait(0.0001) end

Previous comments

0
We need a little bit more information then this. Are there any output errors? Give us some or all of your script. We might be able to help a bit more if we had these things. dyler3 1510 — 9y
0
im trying to keep the code running even if i move the cam(i've used every other loop function but still doesnt work heres the code WeBuiltOurOwnWorld 6 — 9y

1 answer

Log in to vote
0
Answered by
funyun 958 Moderation Voter
9 years ago

1) You need to wait for the character to load before you can access it. I'd do the same for the humanoid just to be safe. 2) You can't disable the "Jump" property like that. The "Jump" property lets you see if the character is jumping, and if you set it to true, the character will jump. Then it immediately gets set back to false. 3) You can't wait for .0001 seconds in Roblox. The frames go by slower than that. Use wait() without adding a number in the parenthesis, and that will wait for about 1/30 of a second. That's the fastest you can go if you don't use RunService. 4) In general, I wouldn't use while true do if I were you. It will lag up the game. Use the Changed event. I'll show you how to do that.

Player = game.Players.LocalPlayer
repeat wait() until Player.Character --Waiting for the character
character = Player.Character
hum = character:WaitForChild("Humanoid") --Waiting for the humanoid
hum.WalkSpeed = 0

hum.Changed:connect(function()

--[[
    There's the Changed event that I was talking about.
    When a property of "hum" changes, like the walkspeed,
    we can then do something.
--]]

    if hum.WalkSpeed ~= 0 then hum.WalkSpeed = 0 end --If it ain't 0, then make it 0.
end
0
still having the problem that when i right click it sets the WalkSpeed to 16 again WeBuiltOurOwnWorld 6 — 9y
Ad

Answer this question