You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want it so this line of code is implemented, but I’m not sure how to do it. -
What is the issue? Include screenshots / videos if possible!
I can’t figure it out.
I want to implement this:
plr.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried implementing it, but it didn’t work.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local SS = game:GetService("ServerStorage")
local Cloneables = SS.Cloneables
local tc_Train = Cloneables.Train
local RS = game:GetService("ReplicatedStorage")
local REs = RS.REs
local rE_Spawn = REs.SpawnTrain
local spawnParts = game.Workspace.SpawnParts:GetChildren()
local currentSpawnIndex = 1
local function CloneTrain(plr)
local spawnPart = spawnParts[currentSpawnIndex]
local train = tc_Train:Clone()
train.Parent = game.Workspace
train:SetPrimaryPartCFrame(spawnPart.CFrame)
-- Remove player from previous seat if they are seated
local previousSeat = plr.Character.Humanoid.SeatPart
if previousSeat then
plr.Character.Humanoid.Sit = false
end
-- Teleport the player to the spawn part and make them sit in the VehicleSeat
local vehicleSeat = train.PrimaryPart:FindFirstChild("VehicleSeat")
if vehicleSeat then
plr.Character.HumanoidRootPart.CFrame = vehicleSeat.CFrame
vehicleSeat:Sit(plr.Character.Humanoid)
-- Set the IsSitting attribute and disable jumping
plr.Character:SetAttribute("IsSitting", true)
plr.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
end
-- Add more SpawnIndexes and change back to original if full
currentSpawnIndex = currentSpawnIndex + 1
if currentSpawnIndex > #spawnParts then
currentSpawnIndex = 1
end
end
rE_Spawn.OnServerEvent:Connect(CloneTrain)