I need help giving a player speed when a tool is clicked

I have a tool “Speed” and when you click it you gain speed which makes your character faster but im having a few problems.

I want it so when you click the sped tool you gain 0.25 speed and when you rebirth it doubles that amount each rebirth.

problem 1) speed is not going up
problem 2) I don’t know how to script the rebirth part
problem 3) when a player dies and respawns their speed is set to normal until they click the speed tool again
problem 4) when a player dies and respawns i get this error - “LoadAnimation requires the Humanoid object (ItzSulfonic.Humanoid) to be a descendant of the game object” inside the tool’s script

This is the serverscript when the tool is clicked

local event = game.ReplicatedStorage:WaitForChild("AddSqa")

	local Stats = player:WaitForChild("leaderstats")
	local speed = Stats:FindFirstChild("speed")
	local rb = Stats:FindFirstChild("rebirths")
    local gain = 1 / 4
	local char = player.Character or player.CharacterAdded:wait()
	if char then
		local hum = char:FindFirstChild("Humanoid")
		if hum then
			speed.Value = speed.Value + gain
			hum.WalkSpeed = speed.Value / 2.5

This is the script inside the tool that fires the event and where im having problem 4.

local db = false
local Tool = script.Parent
local Plr = game.Players.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Humanoid = Char:WaitForChild("Humanoid")
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://6656875234"
local track = Humanoid:LoadAnimation(Anim)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("AddSqa")

	if db == false then 
		db = true
		delay(1, function()
			db = false
1 Like

Is your speed Value a Number or Int value? NumberValues can accept decimals, while IntValues cannot

Just do something like:

			speed.Value = speed.Value + (gain * (Speed.Value / rb.Value or 1))

Use a CharacterAdded event to detect when every time a Character Model gets respawned into the workspace

    local leaderstats = Player:WaitForChild("leaderstats")
    local speed = leaderstats:WaitForChild("speed")

        local Humanoid = Character:WaitForChild("Humanoid")
        Humanoid.WalkSpeed = speed.Value

Try parenting the Animation inside the workspace or the Tool when you create it

Hello there. You are asking the devforum to make an entire rebirth, data presistance and logical parsing systems for you. This is offtopic, however, here are articles that I think will be useful:

When i clicked the tool it set my speed to inf and killed me maybe it has something to do with the player starting off with 0 rebirths?

Also thanks alot i was able to fix the numbervalue and and the CharacterAdded problem

You’d need to come up with some sort of Rebirth System, I just gave a brief example but it shouldn’t be too difficult if you search around maybe :thinking:

gotcha, thanks again for the help

1 Like