I have been trying to make an infection game and I am starting off with the infect script. Whenever a player steps on a hazard they should be "infected". However, in recent tests, all attempts have ended up in all players in the server having the infect sequence play out. I have no clue on how to stop this. Anyone know how to fix this?
Local script (In startercharacterscripts)
local debounce = false
local puddle = game.Workspace.GooClusterMPE.Puddle
local starterPlayer = game:GetService("StarterPlayer")
local plr = game.Players.LocalPlayer
local char = plr.Character
puddle.Touched:Connect(function(touch)
if game.Players.LocalPlayer.Team == game.Teams.Humans then
debounce = true
local Player = game.Players.LocalPlayer
local Character = Player.Character
local animation = game.Workspace.Anims.Animation
local animtrack = Character.Humanoid:LoadAnimation(animation)
local debounce = true
local sound = game.Workspace.Sound
Character.Humanoid.WalkSpeed = 0
game.Players.LocalPlayer.Team = game.Teams.Infected
animtrack:Play()
local repStore = game:GetService("ReplicatedStorage")
local Human = touch.Parent
local sound = game.Workspace.Sound
sound:Play()
--repStore.Transfurs.MPEGoo:FireServer()
wait(1.1)
sound:Play()
wait(2.9)
sound:Play()
wait(1)
sound:Play()
Character.Humanoid.WalkSpeed = 16
end
end)
game.Players.LocalPlayer.Character.Humanoid.Died:Connect(function()
plr.Team = game.Teams.Humans
end)
Server Script
ame.ReplicatedStorage.Transfurs.MPEGoo.OnServerEvent:Connect(function(clientThatFired)
local Player = clientThatFired
local Character = Player.Character
local messyArmL = game.ServerStorage.MessyLimb:Clone()
local messyArmR = game.ServerStorage.MessyLimb:Clone()
local messyLegL = game.ServerStorage.MessyLimb:Clone()
local messyLegR = game.ServerStorage.MessyLimb:Clone()
local messyTorso = game.ServerStorage.MessyTorso:Clone()
local ArmL = Character["Left Arm"]
local ArmR = Character["Right Arm"]
local LegL = Character["Left Leg"]
local LegR = Character["Right Leg"]
local Torso = Character["Torso"]
--Left Arm
local weldAL = Instance.new("WeldConstraint")
weldAL.Part0 = ArmL
weldAL.Part1 = messyArmL
weldAL.Parent = ArmL
messyArmL.Position = ArmL.Position
messyArmL.Orientation = ArmL.Orientation
messyArmL.Parent = game.Workspace
messyArmL.Color = Color3.new(1, 1, 1)
--Right Arm
local weldRA = Instance.new("WeldConstraint")
weldRA.Part0 = ArmR
weldRA.Part1 = messyArmR
weldRA.Parent = ArmR
messyArmR.Position = ArmR.Position
messyArmR.Orientation = ArmR.Orientation
messyArmR.Parent = game.Workspace
messyArmR.Color = Color3.new(1, 1, 1)
--Left Leg
local weldLL = Instance.new("WeldConstraint")
weldLL.Part0 = LegL
weldLL.Part1 = messyLegL
weldLL.Parent = LegL
messyLegL.Position = LegL.Position
messyLegL.Orientation = LegL.Orientation
messyLegL.Parent = game.Workspace
messyLegL.Color = Color3.new(1, 1, 1)
--Right Arm
local weldRL = Instance.new("WeldConstraint")
weldRL.Part0 = LegR
weldRL.Part1 = messyLegR
weldRL.Parent = LegR
messyLegR.Position = LegR.Position
messyLegR.Orientation = LegR.Orientation
messyLegR.Parent = game.Workspace
messyLegR.Color = Color3.new(1, 1, 1)
--Torso
local weldT = Instance.new("WeldConstraint")
weldT.Part0 = Torso
weldT.Part1 = messyTorso
weldT.Parent = Torso
messyTorso.Position = Torso.Position
messyTorso.Orientation = Torso.Orientation
messyTorso.Parent = game.Workspace
messyTorso.Color = Color3.new(1, 1, 1)
--Head
local NewHead = game.ServerStorage.massproducedgoo:Clone()
local OldHead = Character.Head
local headweld = Instance.new("Weld")
headweld.Parent = game.Workspace
headweld.Part0 = OldHead
headweld.Part1 = NewHead.Headroot
NewHead:MoveTo(OldHead.Position)
NewHead.Parent = game.Workspace
OldHead.Color = Color3.new(1, 1, 1)
messyLegL.Transparency = 1
messyLegR.Transparency = 1
messyTorso.Transparency = 1
messyArmL.Transparency = 1
messyArmR.Transparency = 1
wait(0.25)
messyLegL.Transparency = 0.75
messyLegR.Transparency = 0.75
wait(0.25)
messyLegL.Transparency = 0.5
messyLegR.Transparency = 0.5
wait(0.25)
messyLegL.Transparency = 0.25
messyLegR.Transparency = 0.25
wait(0.25)
messyLegL.Transparency = 0
messyLegR.Transparency = 0
wait(0.1)
messyArmL.Transparency = 0.75
messyArmR.Transparency = 0.75
wait(0.25)
messyArmR.Transparency = 0.5
messyArmL.Transparency = 0.5
wait(0.25)
messyArmR.Transparency = 0.25
messyArmL.Transparency = 0.25
wait(0.25)
messyArmR.Transparency = 0
messyArmL.Transparency = 0
messyTorso.Transparency = 1
wait(0.1)
messyTorso.Transparency = 0.75
wait(0.25)
messyTorso.Transparency = 0.5
wait(0.25)
messyTorso.Transparency = 0.25
wait(0.25)
messyTorso.Transparency = 0
end)

2 comments
How do I set this up? I have it set up as "Character = touch.Parent:GetPlayerFromCharacter()" and it still does it. Sorry, I'm somewhat new to coding.
GetPlayerFromCharacter() is called from the Players service, not the part itself. Its only parameter is the part to fetch.