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

How can I enable the player controls in a server script?

I have an issue where If I die while playing an animation that disables my controls, the player won't be able to move after respawning. I need to be able to discern when the player dies, which (I believe) is only able to be done server side, but I also need to be able to enable the controls, which can only be done client side. I tried both a module script and a remove event, and neither would work in this situation. Is there any way to do this or do I have to use a different method to reenable the controls. If you want the code, here

game:GetService('Players').PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(character)
		character:WaitForChild("Humanoid").Died:Connect(function()
			local Controls = require(plr.PlayerScripts.PlayerModule):GetControls()
			local controls = game.Players:GetPlayerFromCharacter("model")
			controls.Controls:Enable(true)
			

		end)
	end)
end)

Error: "PlayerScripts is not a valid member of Player "Players.iiFloxy""

2 answers

✓ Accepted answer

Just put a localscript in StarterCharacterScripts (It will run whenever the character spawns) and enable the controls from there

1 comment

0

This should work If i use a remote event, but you saw on my other question UIS isn't working so I can't confirm if it will work or not yet

I think the issue could be that under the :Connect(function() You use local maybe instead try using script.Parent.Controls = game. --This is an example and you may need to add more .parents. (I don't do much with animations I could be wrong Hope this helps!!)

3 comments

0

that could work, however I can't put the script into the player to use script.Parent

0

also, that doesn't fix the issue of the controls modulescript being clientside only and me having to use a serverscript

0

oh I will try to think of something else

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