Hello, so I am trying to make “Get Faster Every Second” type game. I know I am going to get a lot of hate in this post but oh well. However, I was wondering how I can make it so at spawn, the player’s walkspeed is stuck at 50 and when they go off spawn their speed will go back to what their stats is. I am just trying to figure out how to make it so the player’s speed is locked at spawn so the player doesn’t go flying off at spawn. If you know anything that can stop this, please let me know, thank you.
You can utilize the TouchEnded
event for the SpawnLocation
.
spawnLocation.TouchEnded:Connect(function(basePart: BasePart)
if basePart.Parent then
local humanoid = basePart.Parent:FindFirstChildWhichIsA("Humanoid")
if not humanoid then
return
end
humanoid.WalkSpeed = 16 --// Set this number to whatever the player's stat is.
end
end)
And finally, you can set the game’s default player WalkSpeed
to 50.
1 Like
Sorry uhh, I am not so good at scripting. Should I put this script inside of the part?
If you want a more efficient approach, it is better to use a component based architecture (OOP or ECS) but since you r just staring out, you can paste the script in your part, though keep in mind it is a bad practice if you have many such SpawnLocations, as this breaks the DRY (Don’t Repeat Yourself) principle.
local spawnLocation = script.Parent
spawnLocation.TouchEnded:Connect(function(basePart: BasePart)
if basePart.Parent then
local humanoid = basePart.Parent:FindFirstChildWhichIsA("Humanoid")
if not humanoid then
return
end
humanoid.WalkSpeed = 16 --// Set this number to whatever the player's stat is.
end
end)
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.