hello guys! i made a script that checks a value and depending on the value the player gets speed buffs.
i made a local script in workspace and a string value also in workspace, the script does not run in a local script but it does in a normal script
here is the local script i used:
debounce = 1
Starterplayer = game.StarterPlayer
race = workspace.Race
if debounce == 1 then
print("debouncing")
if race.Value == "Race1" then
Starterplayer.CharacterWalkSpeed += 6
Starterplayer.CharacterJumpPower += 4
print("Race changed to Race1")
debounce = 0
end
if race.Value == "Race2" then
workspace.Damage.Value += 3
Starterplayer.CharacterWalkSpeed += 4
print("Race changed to Race2")
debounce = 0
end
if race.Value == "Race3" then
workspace.Damage += 2
Starterplayer.CharacterWalkSpeed += 5
Starterplayer.CharacterJumpPower += 3
print("Race changed to Race3")
debounce = 0
end
if race.Value == "Race4" then
Starterplayer.CharacterWalkSpeed += 7
workspace.Damage += 2
print("Race changed to Race4")
debounce = 0
end
end
The thing is the code does not run in a local script and also i want to place it in a local script so the entire server does not have to use the same boost/perk/buff. Please help.
Yeah, LocalScripts don’t run under the workspace.
They run under:
Anything that starts with Starter (subfolders of StarterPlayer though)
ReplicatedFirst
So, you can move it to one of those locations, or you can put the code in a normal Script and set the RunContext to Client, because Client scripts that aren’t LocalScripts run under the workspace.
FindFirstChild is different to WaitForChild. If the child isn’t there when FindFirstChild is called, it just returns nil. But, using WaitForChild will wait until the child exists, and also allows you to limit the time it waits for.