Another day, another scripting error... I've been touching up a script for the past few days. It's supposed to weld a part onto the player that touches a hazard. This, of course, has resulted in a lot of bugs with the script. This time, the char (Character) variable doesn't want to work. whenever I step on the hazard, it plays the correct animation through the player's humanoid, but it doesn't changed the walkspeed to 0 nor does it go through with the welding functions. I am at my wit's end trying to fix this and just about to give up. Can you guys help me?
Local script (In StarterCharacter)
local puddle = game.Workspace.GooClusterMPE.Puddle
puddle.Touched:Connect(function(touch)
local plr = game.Players:GetPlayerFromCharacter(touch.Parent)
local char = plr.Character or plr.CharacterAdded:wait()
if plr.Team == game.Teams.Humans then
local animation = game.Workspace.Anims.Animation
local animtrack = char.Humanoid:LoadAnimation(animation)
local sound = game.Workspace.Sound
char.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(plr,char)
char.Humanoid.WalkSpeed = 16
end
end)
game.Players.LocalPlayer.Character.Humanoid.Died:Connect(function(touch)
local plr = game.Players:GetPlayerFromCharacter(touch.Parent)
plr.Team = game.Teams.Humans
end)
Server Script (In ServerScriptService)
game.ReplicatedStorage.Transfurs.MPEGoo.OnServerEvent:Connect(function(plr,char)
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 = char["Left Arm"]
local ArmR = char["Right Arm"]
local LegL = char["Left Leg"]
local LegR = char["Right Leg"]
local Torso = char["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 = char.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
I got it to fire the event and weld without problem, but now the event fires on all clients, causing the part to clone and weld to them.