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

[SOLVED] When I disable and enable ControlModule then respawn I can't move?

Asked by
LawlR 182
5 years ago
Edited 5 years ago
local controlModule = require(plr:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"):WaitForChild("ControlModule"))

repeat wait() until chr:FindFirstChild("Humanoid")

if plr.Team == teams.Beginning then
    local One
    local Tweening = plr.Character:WaitForChild("Tweening")
    if not workspace:FindFirstChild("LocalTouch1") then
        One = LocalTouches:WaitForChild("LocalTouch1"):Clone()
        One.Parent = workspace
    else
        One = workspace:FindFirstChild("LocalTouch1")
    end
    alreadyHit = false
    One.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") and alreadyHit == false then
            spawn(function()
                wait(1)
                One.CanCollide = false
            end)
            alreadyHit = true
            local hum = hit.Parent.Humanoid
            controlModule:Disable()
            -- A bunch of tweening
            Tweening.Value = false
            controlModule:Enable()
        end
    end)
end

This portion of the code causing the issue. It disables the control module when the player touches a part, then enables it once the tweening is done. I do all of this in a local script because it's a single player game, so if the player has a high ping, the stuff will happen instantly instead of a after a delay.

What happens: What the script is meant to do works, however, if the player dies afterwards, then after they respawn they will not be able to move at all. To try and fix this, I added this script into StartercharacterScripts:

local player = game.Players.LocalPlayer
repeat wait() until player.Character
local controlModule = require(player:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"):WaitForChild("ControlModule"))
controlModule:Enable()
print("Enabled")

It prints Enabled but the player is still unable to move. The only way that I could find to make them able to move again is by putting that code into the command bar.

I found a post on the devforum with pretty much the same issue, but it has not been solved. https://devforum.roblox.com/t/new-player-scripts-are-coming-10-11-18-and-how-you-can-prepare/184945/75

Solved: Ended up using ContextActionService thanks to this thread: https://devforum.roblox.com/t/how-to-temporarily-disable-all-character-input/178365/5

0
You can just anchor the HumanoidRootPart in their character , change their walkspeed , jumppower. User#24960 0 — 5y
0
No because I force them to move during the tweening using Humanoid:MoveTo(). LawlR 182 — 5y

Answer this question