Noob game designer here. I am having a weird problem and I would like some suggestions about what is going wrong. I am trying to create a simple spaceship such that when the player presses a button it launches the ship with all of the players inside. To keep the player on the ship I am welding him to the sphere that encloses the whole ship.
In Studio the script works great, but when playing the Game the script does not work because the character is not getting welded to the ship. So he falls through the ship when it lifts off. The code (see below) uses a GetTouchingParts function to create a table of all of the players in the ship (after the ship lifts off they will teleport to another page) and then welds to the ship the members of that table.
Everything works well in Studio it doesn’t work in Game. Any thoughts on what is going wrong and how to fix it? I have videos of the Studio event and the Game event if you think that would help.
Things I have ruled out:
It is not a script commit issue because there is no team coding (I double checked the settings.) Also it does not appear to be a timing issue because adding waits before or in the functions does not solve the problem. I am out of ideas. Anyone?
Here is the relevant part of the code:
local function GetPassangers() – THIS MAKES A LIST OF THE PLAYERS IN THE SHIP
for index, object in pairs(glass:GetTouchingParts()) do --ALL THE PLAYERS TOUCHING THE GLASS SPHERE
if object.Parent:FindFirstChild("Humanoid") ~= nil then
table.insert(Passangers,object.Parent)
object.Parent.Animate.Disabled = true. -- DISABLED ANIMATE BECAUSE WAS GETTING A FALLING ANIMATION
print(Passangers)
elseif object.Parent == nil then
print("stuff")
end
end
end
local function WeldPlayers()
for index, object in pairs(Passangers) do
local part = object:WaitForChild("LowerTorso")
local weld = Instance.new("WeldConstraint")
weld.Enabled = true
weld.Parent = workspace
weld.Part0 = base1
weld.Part1 = part
end
end
ButtonOff.ProximityPrompt.Triggered:Connect(function(Launch).
GetPassangers()
WeldPlayers()
–I BROKE THE PARTS INTO TWO INDEPENDENT FUNCTIONS AND THEN PUT THEM TOGETHER IN THE “LAUNCH” FUNCTION