local gui=seat.ScreenGui:clone() gui.Parent=player.PlayerGui
okay so currently, when a player joins game, the seat's screengui clones to the player
what the problem is is that the server size is more than 1 and the gui only clones one time, how do i rewrite this?
I know about the playeradded logic, but what I'm trying to do is make it so it clones to the playergui when the player sits on the seat, without the gui in the seat being removed
Here is the entire script:
local seat=script.Parent local data=seat.Configuration local owner=nil local running=false local x=0 local y=0 seat.ChildAdded:connect( function(w) if w.className=="Weld" and w.Name=="SeatWeld" then local char=w.Part1.Parent local player=game.Players:FindFirstChild(char.Name) if player~=nil then owner=player seat.ChildRemoved:connect( function(w2) if w2==w then owner=nil end end ) seat.BodyVelocity.maxForce=Vector3.new(1,1,1)*data.MaxForce.Value seat.BodyGyro.maxTorque=Vector3.new(1,1,1)*50000 local spd=0 local gui=seat.ScreenGui:clone() gui.Parent=player.PlayerGui gui.Frame.Faster.MouseButton1Click:connect( function() spd=math.min(spd+data.MaxSpeed.Value/20,data.MaxSpeed.Value) gui.Frame.Speed.Text=math.floor(spd) end ) gui.Frame.Slower.MouseButton1Click:connect( function() spd=math.max(spd-data.MaxSpeed.Value/20,0) gui.Frame.Speed.Text=math.floor(spd) end ) while owner==player do seat.BodyVelocity.velocity=seat.CFrame.lookVector*spd wait() end gui:remove() seat.BodyVelocity.velocity=Vector3.new(0,0,0) seat.BodyVelocity.maxForce=Vector3.new(0,0,0) seat.BodyGyro.maxTorque=Vector3.new(0,0,0) end end end ) seat.Changed:connect( function() if not running then local cur=seat.Steer local cur2=seat.Throttle running=true while (cur~=0 or cur2~=0) do y=y-seat.Steer*data.TurnSpeed.Value x=x-seat.Throttle*data.TurnSpeed.Value seat.BodyGyro.cframe=CFrame.new(0,0,0)*CFrame.Angles(0,math.rad(y),0)*CFrame.Angles(math.rad(x),0,0) wait() end running=false end end )
Well you could make a PlayerAdded
event using the argument for the Player
.... Something like this following code also make sure this code is in a Server-Script
(Normal Script) inside of ServerScriptService
....
game.Players.PlayerAdded:connect(function(player) local gui = seat.ScreenGui:clone() gui.Parent = player.PlayerGui end)