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

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

Asked by 2 years ago

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

Log in to vote
0
Answered by 2 years ago

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

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 iiFloxy 9 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

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!!)

0
that could work, however I can't put the script into the player to use script.Parent iiFloxy 9 — 2y
0
also, that doesn't fix the issue of the controls modulescript being clientside only and me having to use a serverscript iiFloxy 9 — 2y
0
oh I will try to think of something else theking66hayday 841 — 2y

Answer this question