Hello! I started scripting almost a week ago after watching some tutorials and doing some research. Right now I'm trying to make a Tag game but I'm stuck on the most essential part of the game.
local replicatedstorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
replicatedstorage.Debounce.Value = false
wait(20)
local IT = Players[replicatedstorage.NameOfIT.Value]
if IT and IT.Character then
if replicatedstorage.Debounce.Value == false then
IT.Character.Humanoid.Touched:Connect(function(hit)
replicatedstorage.Debounce.Value = true
if Players:GetPlayerFromCharacter(hit.Parent) then
local hitplr = Players:GetPlayerFromCharacter(hit.Parent)
replicatedstorage.Debounce.Value = true
IT.Character.HumanoidRootPart:WaitForChild("Fire").Enabled = false
IT.Character.Humanoid.WalkSpeed = 16
hitplr.Character.Humanoid.WalkSpeed = 40
hitplr.Character.HumanoidRootPart:WaitForChild("Fire").Enabled = true
replicatedstorage.NameOfIT.Value = hitplr.Name
IT = Players[replicatedstorage.NameOfIT.Value]
end
wait(0.5)
replicatedstorage.Debounce.Value = false
end)
end
end
Background information: All players spawn with a disabled fire effect. In the main script, a random player is chosen to be "IT", the chaser. In Replicated Storage I added a NameOfITstring value to keep up with who is currently IT.
My issue is with what happens when IT touches another player (what the script above is for). The first time it happens, it works fine, the hit player becomes IT. However, when this new chaser touches another player things don't go well, because the script doesn't seem to realize that the player described in IT.Character.Humanoid.Touched changed. It's acting as if IT is the same player as before, but the NameOfIT value was changed to the name of the touched player.
I genuinely hope this makes sense. As I said I don't know much about scripting and I've been trying to figure this out by myself for 2 days now. Any help will be greatly appreciated!
