Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

2 comments

0

any errors?

0

Nope there is no any error :/

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.