My goal is to make the auto jump system to make the player jump 10 times every 10 second if the signal type is “autojump” and I also want the freeze system to freeze player when signal type is “freeze” by set speed to 0 and disable jumping state of humanoid. But, the main problem is the :ChangeState() not working and I assuming it is something relate about between the client and server.
Server:
EventsManager.OnServerEvent:Connect(function(Player: Player, SignalType: string, ClientData: {})
SignalType = string.lower(tostring(SignalType))
if SignalType == 'fling' then
EventsManager:FireAllClients('sendchatmsg', {
MessageData = {
Text = `{ClientData.Target.DisplayName} has been trolled by {Player.DisplayName} using fling troll`,
Color = Color3.fromRGB(255, 0, 0),
};
Message = `<font color = "rgb(255, 0, 0)">{ClientData.Target.DisplayName} has been trolled by {Player.DisplayName} using fling troll</font>`
})
local TargetChar = ClientData.Target.Character or ClientData.Target.CharacterAdded:Wait()
local TargetHrp = TargetChar:WaitForChild('HumanoidRootPart') or TargetChar.PrimaryPart
local TargetHum = TargetChar:WaitForChild('Humanoid')
local NewRagdoll = RagdollModule.new(TargetChar, {
KnockbackOnRagdoll = {
Enabled = true;
Direction = TargetChar:GetPivot().Position + TargetChar:GetPivot().UpVector * 120;
Duration = .35;
};
DamageOnRagdoll = {
Enabled = false;
Damage = 10;
};
})
TargetHrp.CanCollide = false
NewRagdoll:Run('Ragdoll')
task.delay(5, function()
NewRagdoll:Run('Recover')
TargetHrp.CanCollide = true
end)
elseif SignalType == 'explode' then
EventsManager:FireAllClients('sendchatmsg', {
MessageData = {
Text = `{ClientData.Target.DisplayName} has been trolled by {Player.DisplayName} using explode troll`,
Color = Color3.fromRGB(255, 0, 0),
};
Message = `<font color = "rgb(255, 0, 0)">{ClientData.Target.DisplayName} has been trolled by {Player.DisplayName} using explode troll</font>`
})
local TargetChar = ClientData.Target.Character or ClientData.Target.CharacterAdded:Wait()
local TargetHrp = TargetChar:WaitForChild('HumanoidRootPart') or TargetChar.PrimaryPart
local Explosion = Instance.new('Explosion', TargetHrp)
Explosion.Position = TargetHrp.Position
Explosion.BlastPressure = 10000
elseif SignalType == 'kick' then
ClientData.Target:Kick(`You have been trolled by {Player.Name}`)
elseif SignalType == 'kill' then
local TargetChar = ClientData.Target.Character or ClientData.Target.CharacterAdded:Wait()
local TargetHum = TargetChar:WaitForChild('Humanoid')
TargetHum:TakeDamage(TargetHum.MaxHealth)
elseif SignalType == 'autojump' then
local TargetHum = ClientData.Hum
if not JumpsList[TargetHum] then
JumpsList[TargetHum] = 0
end
task.spawn(function()
while JumpsList[TargetHum] and JumpsList[TargetHum] < 10 do
task.wait(1)
JumpsList[TargetHum] += 1
TargetHum:ChangeState(Enum.HumanoidStateType.Dead)
print(TargetHum:GetState())
if JumpsList[TargetHum] >= 10 then
print(TargetHum)
JumpsList[TargetHum] = 0
end
end
end)
elseif SignalType == 'freeze' then
local TargetHum = ClientData.Hum
print(TargetHum)
TargetHum.WalkSpeed = 0
TargetHum:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
task.delay(10, function()
TargetHum.WalkSpeed = StarterPlayer.CharacterWalkSpeed
TargetHum:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
end)
end
end)
Client:
AutojumpBtn.MouseButton1Click:Connect(function()
local SpectateValue = Char:FindFirstChild('SpectateTarget')
if SpectateValue and SpectateValue:IsA('ObjectValue') then
assert(SpectateValue.Value and SpectateValue.Value:IsA('Player'), 'SpectateValue value is not a player!!')
local TargetChar = SpectateValue.Value.Character or SpectateValue.Value.CharacterAdded:Wait()
local TargetHum = TargetChar:WaitForChild('Humanoid')
EventsManager:FireServer('AutoJump', {
Hum = TargetHum
})
end
end)
FreezeBtn.MouseButton1Click:Connect(function()
local SpectateValue = Char:FindFirstChild('SpectateTarget')
if SpectateValue and SpectateValue:IsA('ObjectValue') then
assert(SpectateValue.Value:IsA('Player'), 'SpectateValue value is not a player!!')
local TargetChar = SpectateValue.Value.Character or SpectateValue.Value.CharacterAdded:Wait()
local TargetHum = TargetChar:WaitForChild('Humanoid')
EventsManager:FireServer('Freeze', {
Hum = TargetHum
})
end
end)