So the problem is that i fired a remote event and then i want some if statements in the server but the health is 100 on the server but 0 on the client idk why?
local script -
local character = game.Players.LocalPlayer.Character
local Player = game.Players:GetPlayerFromCharacter(character)
local hum = character:WaitForChild("Humanoid")
local Event = game:GetService("ReplicatedStorage"):WaitForChild("Ragdoll"):WaitForChild("PlayerDied")
hum:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
hum.HealthChanged:Connect(function(health)
if health <= 0 then
print(health)
Event:FireServer()
print("Hello")
end
end)
ServerScript -
game.ReplicatedStorage:WaitForChild("Ragdoll"):WaitForChild("PlayerDied").OnServerEvent:Connect(function(Player)
print(Player.Character.Humanoid.Health)
local Char = Player.Character
print("Fired")
Char.Humanoid.WalkSpeed = 0
Char.Humanoid.JumpPower = 0
Char.Humanoid.JumpHeight = 0
for i, v in pairs(Char:GetDescendants()) do
if v:IsA("Motor6D") then
local Socket = Instance.new("BallSocketConstraint")
local Attachment = Instance.new("Attachment")
Attachment.Name = "Attachment1"
local Attachment2 = Instance.new("Attachment")
Attachment.Parent = v.Part0
Attachment2.Parent = v.Part1
Socket.Parent = v.Parent
Socket.Attachment0 = Attachment
Socket.Attachment1 = Attachment2
Attachment.CFrame = v.C0
Attachment2.CFrame = v.C1
Socket.LimitsEnabled = true
Socket.TwistLimitsEnabled = true
v:Destroy()
end
while Player.Character.Humanoid.Health < 100 do
print("Hey sussy")
Player.Character.Humanoid.Health += 1
wait(1)
end
end
Char.Humanoid.HealthChanged:Connect(function(Health)
if Health > Char.Humanoid.MaxHealth / 0.5 then
for i, v in pairs(Char:GetDescendants()) do
if v.Name == "BallSocketConstraint" then
v:Destroy()
end
if v.Name == "Attachment1" then
v:Destroy()
end
if v.Name == "Attachment" then
v:Destroy()
end
end
end
end)
end)