Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why i can't turn Ragdoll Effect on from Server Script ?

Asked by 4 years ago
Edited 4 years ago

Hey. I'm using ragdoll script of 'EchoReaper'. There is no problem with ragdoll script but i need to make player ragdoll from server. I modified the local script which it's originally binding R key to ragdoll on and off. When i fire the client from server ragdoll working perfectly. Here is my Local Script :

local function ragdoll()
    local setEnabled = humanoid:GetState() ~= Enum.HumanoidStateType.Physics
        humanoid:ChangeState(setEnabled and Enum.HumanoidStateType.Physics or Enum.HumanoidStateType.GettingUp)
        character.Animate.Disabled = setEnabled

        if setEnabled then
            for _,v in pairs(humanoid:GetPlayingAnimationTracks()) do
                v:Stop(0)
            end
        end
end

remote.OnClientEvent:Connect(ragdoll)

but user can remove this local script to avoid ragdoll effect. When i try to run this code from server it's not working and i don't know what is the problem. Here my server script :

game.Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local energy = Instance.new("IntValue")
    energy.Name = "Energy"
    energy.Value = 10
    energy.Parent = leaderstats

    local char = game.Workspace:WaitForChild(player.Name)
    local hum = char:WaitForChild("Humanoid")
    while hum do
        wait()
        if energy.Value > 0 then
            wait(1)
            if hum.MoveDirection.Magnitude > 0 then
                energy.Value = energy.Value - 1
            end
        elseif frozen == false then
            frozen = true
            --remote:FireClient(player) When i use this it's working...
            --This codes below are not working from 'server script'
            local setEnabled = hum:GetState() ~= Enum.HumanoidStateType.Physics
            hum:ChangeState(setEnabled and Enum.HumanoidStateType.Physics or Enum.HumanoidStateType.GettingUp)
            char.Animate.Disabled = setEnabled

            if setEnabled then
                for _,v in pairs(hum:GetPlayingAnimationTracks()) do
                    v:Stop(0)
                end
            end
        end
    end
end)
0
any errors? User#30567 0 — 4y
0
Nope there is no any error :/ GeldiBaskan 13 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Well it's bad but we can't use 'humanoid:ChangeState' and 'humanoid:GetPlayingAnimationTracks' on server script.. So there is no way to make rogdoll effect exploit proof.

Ad

Answer this question