Hello,
Working on a King of the Hill-type script. Script works, but the points are adding too fast when the player is touching the part. Any thoughts on how I can adjust the script to where the Points stop being added so fast? Debounce? More Breaks? I've tried putting in a debounce in a couple places, but I appears to be using them incorrectly. I add in waits, but it just delays the mass of points being added at once. I need to make sure points are not being added if the scoreBase is not being touched.
Script:
local function ScorePartTouched(scoreObject) local scoreBase = scoreObject.scoreBase scoreBase.Touched:connect(function(otherPart) local player = Players:GetPlayerFromCharacter(otherPart.Parent) wait(1) if (player == nil) then return --end elseif (player ~= nil) then wait(1) PointAdderEvent:Fire(player) --Bindable Event return end end) end
The Bindable Event adding the points:
PointAdderEvent.Event:Connect(function(player) local team1 = game.Teams.Team1 local team2 = game.Teams.Team2 local PlayersT1 = team1:GetPlayers() local PlayersT2 = team2:GetPlayers() local replicatedstorage = game:GetService('ReplicatedStorage') local serversettings = replicatedstorage.ServerSettings local Team1score = serversettings.Team1Score local Team2score = serversettings.Team2Score if player.TeamColor == team1.TeamColor then Team1score.Value = Team1score.Value + 1 elseif player.TeamColor == team2.TeamColor then Team2score.Value = Team2score.Value + 1 end end)
Thank you for taking a look! :)