So, currently I’m testing how the player will (automatically) move to and from the shop, disabling controls as well to prevent interruption.
For some reason, after the controls have been disabled and re-enabled once, if the character respawns, it will refuse to move or jump.
The LocalScript that does this is parented under a ScreenGUI, which has its default properties at the moment. I can’t really figure out what could be the issue, since I doubt shopTrigger.Touched
is being called more than once, so I can’t think of a solution right now…
Here’s the Touched event:
shopTrigger.Touched:Connect(function(otherPart: BasePart)
local humanoid = getAliveHumanoidFromOtherPart(otherPart)
if debounce > 0 or not humanoid or not (humanoid and humanoid.Parent ~= LocalPlayer.Character) then return end
debounce = 3 -- Prevents player from interacting with shopTrigger again. Only ticks down once inShop is false.
inShop = true
Controls:Disable()
spawn(function()
humanoid:MoveTo(Vector3.new(40, -27.5, 97.5)) -- Should be in front of the shop stand i think
humanoid.MoveToFinished:Wait()
Chat:Chat(workspace.Shop.ShopKeep.Head, "Oh, hey, the shop isn't ready yet. Come back later.")
-- use CFrames, dont tween Orientation directly, or character will glide into floor for some reason
local tween = game:GetService("TweenService"):Create(humanoid.Parent.PrimaryPart, TweenInfo.new(1), {["CFrame"]=CFrame.lookAt(humanoid.Parent.PrimaryPart.Position, workspace.Shop.ShopKeep.HumanoidRootPart.Position)})
tween:Play()
end)
task.wait(2.5)
humanoid:MoveTo(Vector3.new(40, -27.5, 85.5)) -- Further away, so its not touching shopTrigger
humanoid.MoveToFinished:Wait()
Controls:Enable()
inShop = false
end)
I’m still fairly new to programming, so any and all help is appreciated! If you want / need the entire script, I can probably send it here, since it isn’t too big at the moment.