Since ROBLOX made it so it’s a module you have to use their functions to disable player movement. I have a script that does that, then re enables it after a set amount of time, right? However, I’ve found upon spawning players lose their ability to move, and the control module is set to disabled forever. I don’t know why this happens though.
.In the future, please post your code to your thread in a code block as opposed to an image of your code. It makes it better for us so we can interact with your code (copy and paste). There’s also not enough information here - knowing your object hierarchy would be fantastic.
That being said, I created a quick repro to see if I could repro the error.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEventObject = ReplicatedStorage:WaitForChild("RemoteEventObject")
local PlayerModule = require(script.Parent:WaitForChild("PlayerModule"))
local Controls = PlayerModule:GetControls()
RemoteEventObject.OnClientEvent:Connect(function (task)
if task == "A" then
Controls:Disable()
wait(8)
Controls:Enable()
end
end)
Self explanatory, hopefully. This script was in PlayerScripts. Encountered no issues, even after spawning in and going on a break frenzy.
I assume the issue is where your script is located. When players spawn in, the old instance is wiped and the thread terminates during the wait(2), which results in a permanent controls disabling.
If this is the case, what is the actual solution to fixing an issue like this?
(I’m new to the forums to please excuse me if I’m not supposed to post on old threads!)
So just to clarify - before a player dies, I’m supposed to parent the script that enabled/disabled the PlayerControl module initially to replicated storage and after the player respawns I’m supposed to parent the same script back to the player?
Oh, my apologies. Keep the client script receiving the fired event in PlayerScripts, and follow @colbert2677’s example to make sure the thread won’t terminate when the player respawns. I believe, because the script isn’t in CharacterScripts, it won’t automatically replicate itself if the character dies.
Sorry for the confusion.