I have recently discovered a bug in one of my infection games that cause all players to have the infection animation play when one of the players touches a hazard. I am currently reworking the code, this time attempting it with the GetPlayerFromCharacter()
function. However, now that I implemented this, I get an error in the console that says GetPlayerFromCharacter is not a valid member of Model "Workspace.Crimsonknightzone"
How do I fix this?
Here is the code, it's on a local script
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 playerWhoTouched = touch.Parent local Player = playerWhoTouched:GetPlayerFromCharacter() 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)