I’m making a winning system in which if the player touches the trophy at the end then they will win and then the time will speed up by an exponential amount, basically what TOH does when you reach the top
what it does currently is if the player keeps on touching the trophy the multiplier will just go up a bunch instead of 1 time and it doesn’t check if the player has already touched the trophy
here’s the script
local trophy = script.Parent.Touch -- the hit box basically
local multiplier = game.ServerScriptService.RoundSystem.Multiplier
local function PlayerTouched(Part)
local Parent = Part.Parent
if game.Players:GetPlayerFromCharacter(Parent) then
multiplier.Value = multiplier.Value * 2 -- speeds up the time by 2 every time a player has touched the trophy
end
end
local touchedPlayers = {}
local trophy = script.Parent.Touch
local multiplier = game.ServerScriptService.RoundSystem.Multiplier
local function PlayerTouched(part)
local player = game.Players:GetPlayerFromCharacter(par
Add a BoolValue to each player then change it to true when the player touches it.
Check in your PlayerTouched if the bool is true in the player that just touched it. If it’s true then don’t increase the multiplier.
You could use a bool value if you want it to be like already touched forever per account use data stores if not then use a bool value.
local trophy = script.Parent.Touch -- the hit box basically
local multiplier = game.ServerScriptService.RoundSystem.Multiplier
local function PlayerTouched(Part)
local Parent = Part.Parent
local plr = game.Players:GetPlayerFromCharacter(Parent)
if plr then
if plr.HasTouched.Value == false then
multiplier.Value = multiplier.Value * 2 -- speeds up the time by 2 every time a player has touched the trophy
plr.HasTouched.Value = true
end
end
end```
you can use a variable that will be set to true when the part is touched, and in the script check the value of the variable. if it is false then set it to true and do whatever else you want, if it is true then do nothing.
i had to change a tiny bit of code at the top cause the function wasn’t working but in the end, I got it to work, Thanks.
Brant
here’s the code if you want to know what i changed
local trophy = script.Parent.Touch
local multiplier = game.ServerScriptService.RoundSystem.Multiplier
trophy.Touched:Connect(function(Part)
local Parent = Part.Parent
local player = game.Players:GetPlayerFromCharacter(Parent)
if player then
if player.HasWon.Value == false then
multiplier.Value = multiplier.Value * 2
player.HasWon.Value = true
print("player has won and changed value")
end
end
end)