I’m trying to make a script where the player that touches a part get his leaderstats changed, but I’m struggling how could I make the same player dont get the score from the same part, I even tryed localscripts and creating ObjectValues but nothing seems to work.
Here’s the server script:
local part = script.Parent
local plrDeb = false
part.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local PlrsTouched = part.PlayersTouched
local PlayerVal = Instance.new("ObjectValue")
PlayerVal.Parent = PlrsTouched
PlayerVal.Value = player
if player ~= PlayerVal and plrDeb == false then
local HeighValue = player:WaitForChild("leaderstats"):WaitForChild("Heigh")
HeighValue.Value = HeighValue.Value + 0.5
plrDeb = true
wait(0.01)
plrDeb = false
end
end
end)
and here is the LocalScript:
local part = script.Parent
part.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum then
part.ScoreGivingScript.Enabled = false
end
end)
If anyone help me fixing the issue I will be grateful!