Speed game script help!

How would i make a game where when you die you get slower but when you get a kill you get faster. THANKS

3 Likes

To create a game where players get slower when they die but faster when they get a kill, you can follow these steps:

  1. Set up a variable to keep track of the player’s speed. Initialize it with a default speed value.
  2. Implement a function to handle the player’s death. In this function, decrease the player’s speed by a certain amount.
  3. Implement a function to handle the player’s kill. In this function, increase the player’s speed by a certain amount.
  4. Listen for player deaths and kills in your game. When a player dies, call the death function to decrease their speed. When a player gets a kill, call the kill function to increase their speed.
  5. Update the player’s speed value in real-time. You can use a loop or an update function to continuously adjust the player’s speed based on their kills and deaths.
1 Like

Could you write an example for me?

1 Like

yes, I can do it.

local player = game:GetService("Players").LocalPlayer -- Assuming you're working with local player
local speed = 16 -- Default speed value
local deathSpeedDecrease = 4 -- Amount to decrease speed when the player dies
local killSpeedIncrease = 2 -- Amount to increase speed when the player gets a kill

local function handleDeath()
    speed = speed - deathSpeedDecrease
end

local function handleKill()
    speed = speed + killSpeedIncrease
end

local function updateSpeed()
    player.Character.Humanoid.WalkSpeed = speed -- Adjust the player's speed
end

-- Listen for player deaths and kills
player.CharacterAdded:Connect(function(character)
    character:WaitForChild("Humanoid").Died:Connect(handleDeath)
end)

-- Assuming you have a way to track player kills, listen for kills and call the kill function
game:GetService("ReplicatedStorage").PlayerKilledEvent.OnClientEvent:Connect(handleKill)

-- Continuously update the player's speed
while wait(0.1) do
    updateSpeed()
end

if you need any question you can talk to me again.

SIDE question, could you make it so instead of changing speed, you change the health.

local player = game:GetService("Players").LocalPlayer -- Assuming you're working with local player
local maxHealth = 100 -- Maximum health value
local deathHealthDecrease = 20 -- Amount to decrease health when the player dies
local killHealthIncrease = 10 -- Amount to increase health when the player gets a kill

local function handleDeath()
    local humanoid = player.Character:WaitForChild("Humanoid")
    humanoid.Health = humanoid.Health - deathHealthDecrease
end

local function handleKill()
    local humanoid = player.Character:WaitForChild("Humanoid")
    humanoid.Health = humanoid.Health + killHealthIncrease
end

-- Listen for player deaths and kills
player.CharacterAdded:Connect(function(character)
    local humanoid = character:WaitForChild("Humanoid")
    humanoid.Died:Connect(handleDeath)
end)

-- Assuming you have a way to track player kills, listen for kills and call the kill function
game:GetService("ReplicatedStorage").PlayerKilledEvent.OnClientEvent:Connect(handleKill)

Will this script work if I put it into a script in the workspace?

yes, put in there and it have to work well!

Could you make it so you get banned for 1hour when you lose all your health but then it resets? Also I think there is some confusion, the maxhealth should go up/down instead of the playerhealth.

you’re really making @Thecrazyhaaks123 script for you :joy:

1 Like

nah I dont do more, im are tired