If you downvote this, please post why you did! The script is supposed to print (name of player) sat on seat, and then it is supposed to make the recover text (inside recovering GUI) visible! Why isn't that happening? Here is the script
local plr = nil; script.Parent.ChildAdded:connect(function (obj) if (not obj:IsA("Weld")) then return; end if (plr ~= nil) then return; end local tors = obj.Part1; local char = tors.Parent; plr = game.Players:findFirstChild(char.Name); if (plr == nil) then return; end print(plr.Name.." sat on this seat"); wait(1)--my part starts here function onTouched(hit) print("touched") print(hit.Name) print(hit.Parent.Name) plr.PlayerGui.Recovering.Recover.Visible = true end end); script.Parent.Parent.Foot1.Touched:connect(onTouched)
Please help!!! Thank you!!! P.S. It does print _____ sat on this seat
I don't really understand what you are trying to do with the following lines as they are opposite arguments?
if (plr ~= nil) then return; end if (plr == nil) then return; end
The script below needs to be placed into the seat to work.
I have added remove gui if needed.
--player sat down show gui script.Parent.ChildAdded:connect(function (ins) if ins.Name == "SeatWeld" then -- child is weld, i dont know if this is a default name? local wplr = ins.Part1.Parent --player print(wplr) -- workspace character local gplr = game.Players:GetPlayerFromCharacter(wplr) -- get game player print(gplr) -- game players if gplr ~= nil then -- checks in plr exists gplr.PlayerGui.ScreenGui.Frame.Visible = true -- show gui ot text end end end) --player stood up hide gui script.Parent.ChildRemoved:connect(function (ins) if ins.Name == "SeatWeld" then -- child is weld, i dont know if this is a default name? local wplr = ins.Part1.Parent --player print(wplr) -- workspace character local gplr = game.Players:GetPlayerFromCharacter(wplr) -- get game player print(gplr) -- game players if gplr ~= nil then -- checks in plr exists gplr.PlayerGui.ScreenGui.Frame.Visible = false -- show gui ot text end end end)