-
What do you want to achieve? Keep it simple and clear!
I’m trying to disable then re-enable player controls. -
What is the issue? Include enough details if possible!
The controls get disabled but don’t re-enable. I am using this in a local script. -
What solutions have you thought of so far?
I’ve tried waiting for a couple seconds and requiring the player module separately.
Here’s my script:
local ts = game:GetService("TweenService")
local playermodule = require(game.Players.LocalPlayer.PlayerScripts.PlayerModule)
local tempkeyframe = game:GetService("KeyframeSequenceProvider") --temporary anim (please replace with anim id)
local firing = false
local camera = workspace.CurrentCamera
game.ReplicatedStorage.Dies.TripAndDie.OnClientEvent:Connect(
function()
if firing == false then
firing = true
local hash = tempkeyframe:RegisterKeyframeSequence(workspace.Dies.Anims.TripAndDie.AnimSaves.tripanddie) --temp
local anim = Instance.new("Animation") --temp
anim.AnimationId = hash--temp
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = camera.CFrame * CFrame.Angles(0, 0, 0) --set the camera orientation to zero so it doesn't get added on
playermodule:GetControls():Enable(false)
game.Players.LocalPlayer.Character.PrimaryPart:PivotTo(workspace.Dies.Anims.TripAndDie.PrimaryPart.CFrame) --teleports player to r15 model for anim
local tween =
ts:Create(camera,TweenInfo.new(1, Enum.EasingStyle.Quad),{CFrame = CFrame.new(-93.4, 11.6, 67.6) * CFrame.Angles(0, math.rad(90), 0)}) --tweens camera to position (kinda tilts the camera but it looks good? so.. yup i did that on porpose :)
tween:Play()
task.wait(0.5)
tween.Completed:Wait()
local playedanim = game.Players.LocalPlayer.Character.Humanoid.Animator:LoadAnimation(anim)
playedanim:Play()
repeat
task.wait(0.01)
until playedanim.IsPlaying == false
game.Players.LocalPlayer.Character.Humanoid.Health = 0
task.wait(3)
print("hey")
camera.CameraType = Enum.CameraType.Custom
print("set camera type back")
firing = false
print("set firing to false")
playermodule:GetControls():Enable(true) --not running
print("enabled controls")
else
end
end
)