So, I'm trying to make some attachments for a rollercoaster system which I am currentley building but, the code is failing to create them and put them in the designated workspace.
function SetupLiftHills() local ChainAttachment1 = Instance.new("Attachment") ChainAttachment1.Name = "ChainAttachment1" ChainAttachment1.Parent = game.Workspace.Ride.Chains.LiftHill.Chain.Start print("Created Successfully") local ChainAttachment2 = Instance.new("Attachment") ChainAttachment2.Name = "ChainAttachment2" ChainAttachment2.Parent = game.Workspace.Ride.Chains.LiftHill.Chain.End print("Created Successfully") end
I only typed this for executing the code and I feel that is where the problem is or it might be my code itself.
SetupLiftHills()
I am firing the code as I have added a statement right at the bottom of my code which specifies the function but, it doesn't appear to run at all.
Hello,
Maybe your Attachments are not parented to a Base-part, or you may have simply messed up your code, try using this code instead
local Chain = game.Workspace.Ride.Chains.LiftHill.Chain function SetUpLiftHills() local Attachment0 = Instance.new("Attachment", Chain.Start) -- Simpler Attachment.Name = "ChainAttachment0" local Attachment1 = Instance.new("Attachment", Chain.End) Attachment.Name = "ChainAttachment1" end
Activate Function
SetUpLiftHills()
If this doesn't work, check if End
and Start
are Parts or Not.
To Set A lot of Attachments:
Loop through all the Children in the Chain and give them attachments
local Chain = game.Workspace.Ride.Chains.LiftHill.Chain function SetUpLiftHills() for Number, Chains in pairs(Chain:GetChildren()) do local Attachment = Instance.new("Attachment", Chains) -- Simpler Attachment.Name = "ChainAttachment"..Number -- sets the names end end
Activate function
SetUpLiftHills()