I am very grateful to you for your efforts and help, but unfortunately it still does not work
why are you cloning the model every loop? what exactly are you trying to do?
making the player sit would be as simple as putting a local script in the button
similar to what @LaterThenDo suggested
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Seats = model.seats:GetChildren() -- this would error, what is model?
script.Parent.MouseButton1Click:Connect(function()
for i, seat in pairs(Seats) do
if not seat.Occupant then
seat:Sit(Humanoid)
Humanoid.JumpHeight = 0
break
end
end
end)
Yes, I could do it through a local script but I’ve seen a lot of posts about Sit() and a lot of people have this problem that it doesn’t work in local scripts
it does work in LocalScripts fortunately
Personally, the Sit() function does not work for me in local scripts, you can check it in roblox studio
it does work in LocalScripts
you must’ve done something wrong
show me what you did
Maybe try removing the server event from the loop. Instead just make a new LocalScript in the TextButton
local plr = game:GetService("Players").LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
if plr then
local Seats = model.seats:GetChildren()
for i, seat in pairs(Seats) do
if not seat.Occupant then
seat:Sit(plr.Character.Humanoid)
plr.Character.Humanoid.JumpHeight = 0
break
end
end
end
end)
That would work if it does mark me as the solution. You see when you do this it automatically makes an argument called player, you just need to assign a name to it
You also dont ned to check if plr then
Bro, that’s completly wrong.
You don’t use the StarterGui for gui!!!
Yay! Sorry for claiming that Sit() doesn’t work in local scripts, everything actually works, I just put the local script where it doesn’t work, thank you very much for your help
Thank you all for your responsiveness. I appreciate it
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.