local Glider_S = {}
--//Services
local ServerStorage = game:GetService("ServerStorage")
local Gliders = ServerStorage.Assets.Gliders
function Glider_S.EquipGlider(player, glider)
local Character = player.Character or player.CharacterAdded:Wait()
if Character then
local Glider = Gliders[glider]:Clone()
Glider.Parent = workspace
Glider.PrimaryPart:SetNetworkOwner(player)
local Attachment = Glider.Frame:FindFirstChild("Attachment", true)
local motor = Instance.new("Motor6D")
motor.Name = "GliderMotor"
motor.Part0 = Character.Head
motor.Part1 = glider.PrimaryPart
motor.C0 = CFrame.new(0, 0, 0)
motor.C1 = Character.Head.CFrame * CFrame.new(0,3,0)
if Attachment and Attachment:IsA("Attachment") then
motor.C1 = Attachment.CFrame:Inverse()
end
motor.Parent = Character.Head
end
end
return Glider_S
I really have no idea why this happens, but it just does not position the glider above the character. It does not position the glider at all
You shouldn’t have variables with the same names as actual Roblox items (ex: Character or Attachment) to keep the engine (and us reading the script) from getting confused as to what you are dealing with.
A better way is to make the first letter lower case so there is no confusion. I’ve done that below in the examples:
local character = player.Character or player.CharacterAdded:Wait()
print("character = ", character)
if character then -- code
and
print("attachment = ", attachment)
if attachment and attachment:IsA("Attachment") then
motor.C1 = attachment.CFrame:Inverse()
end
This lets you know what the variables actually are instead of what you’d expect them to be, which helps troubleshoot problems. If they aren’t what you expect you can go back and look at what sets the variable in each case.
Does it have something to do with the fact that you’re setting motor.C1 twice? If you just cut the first one and place it by itself in the if Attachment section does it work?
(And I don’t think you have to set motor.C0 to 0,0,0 since that’s the default setting anyway.)