I’m trying to make a zombie transformer by touching a part.
The problem is if I run over the part, the animations break, but if I jump on top of the part, the animations work perfectly.
I assume this is because of the humanoid’s state type and I’ve tried setting this but nothing has worked.
**Important Information**
Server:
local CollectionService = game:GetService("CollectionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local DebounceTable = {}
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character["Body Colors"]:Destroy()
end)
end)
local function Touched(v)
return function(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent)
if not player then return end
if DebounceTable[player] then return end
DebounceTable[player] = player
ReplicatedStorage.Zombify:FireAllClients("FX",player.Character)
end
end
for i,v in CollectionService:GetTagged("ZombieTransformer") do
v.Touched:Connect(Touched(v))
end
CollectionService:GetInstanceAddedSignal("ZombieTransformer"):Connect(function(v)
v.Touched:Connect(Touched(v))
end)
ReplicatedStorage.Zombify.OnServerEvent:Connect(function(player,signal)
if signal == "ZombieAnimate" then
player.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Landed)
player.Character.Animate.Enabled = false
local new = script.ZombieAnimate:Clone()
new.Parent = player.Character
end
end)
Client:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FX = require(script.FX)
local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
ReplicatedStorage.Zombify.OnClientEvent:Connect(function(signal,character)
if signal == "FX" then
FX.new(character):Init()
end
end)
FX:
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GeneralInfo = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
local InZombieState = false
local FX = {}
FX.__index = FX
function FX.new(character)
local self = setmetatable({},FX)
self.Target = character
self.Humanoid = self.Target.Humanoid
self.Head = character.Head
return self
end
function FX:Init()
ReplicatedStorage.Zombify:FireServer("ZombieAnimate")
self:ZombieFace()
self:FadeGreen()
self:Sounds()
end
function FX:FadeGreen()
for i,v in self.Target:GetChildren() do
if not v:IsA("BasePart") then continue end
TweenService:Create(v,GeneralInfo,{Color = Color3.fromRGB(111, 156, 81)}):Play()
end
end
function FX:Sounds()
task.spawn(function()
while true do
local sounds = {script.Zombie1,script.Zombie2}
local sound = sounds[math.random(1,#sounds)]:Clone()
sound:Play()
sound.Parent = self.Target
task.delay(sound.TimeLength,sound.Destroy,sound)
task.wait(10)
end
end)
end
function FX:ZombieFace()
self.Head.face.Texture = script.ID.Texture
end
return FX