So I’ve got a local script in StarterCharacterScripts, and it’s binded using CAS. When you first spawn in, the print statement in it DOES print and prints CORRECTLY, yet there is no AlignPosition in the explorer, nor does the player get moved. After resetting your character, the script works as intended.
How do I make it work on the initial spawn?
local function movementHandler(actionName, inputState, inputObject)
local tempData = httpService:JSONDecode(data.Value)
if actionName == "Dash" and inputState == Enum.UserInputState.Begin and dashCooldown then
dashCooldown = false
local dashDistance = 20
for _, skill in pairs(tempData["Skills"]) do
dashDistance += skills[skill]["DashDistance"]["Additive"]
end
for _, skill in pairs(tempData["Skills"]) do
dashDistance *= skills[skill]["DashDistance"]["Multiplicative"]
end
character["Left Arm"].Trail.Enabled, character["Right Arm"].Trail.Enabled = true, true
local alignPosition = script.AlignPosition:Clone()
alignPosition.MaxForce, alignPosition.Attachment0, alignPosition.Parent, alignPosition.Position = dashDistance * 1000, humanoidRootPart.AlignPositionAttachment, humanoidRootPart, (humanoidRootPart.CFrame * CFrame.new(0, 0, -dashDistance)).Position
print(alignPosition.Parent.Parent, alignPosition.Parent)
task.wait(0.2)
alignPosition:Destroy()
character["Left Arm"].Trail.Enabled, character["Right Arm"].Trail.Enabled = false, false
task.wait(1.8)
dashCooldown = true
end
end
contextActionService:BindAction("Dash", movementHandler, true, Enum.KeyCode.Q, Enum.KeyCode.ButtonL3)
Before you answer:
YES, it is a local script
YES, it is in StarterCharacterScripts
YES, all variables are correct
If you did not read my post, I said all variables are correct and already explained that it runs correctly after resetting, I just left the global variables out as there are no issues with them and it is assumed they’re there.
I’m going to mark this as solved, it has seemingly fixed itself, my only guess is that it was either some temporary engine bug, or some other script in my game somehow caused it.