Hello,
I have a question. This script below was working before (I guess, I'm not really sure anymore), but now it doesn't. I don't know why. It's supposed to work like this: When the player has sat, a GUI will pop up and once the player left the seat, it'll remove. Could anyone tell me why this script isn't working?
local vehicleseat = script.Parent local GUI = script.DeleteGUI script.Parent.Changed:connect(function(property) if property == "Occupant" then local humanoid = vehicleseat.Occupant if humanoid then GUI:clone().Parent = game.Players:GetPlayerfromcharacter(humanoid.Parent):WaitForChild("PlayerGui") else game.Players:GetPlayerFromCharacter(humanoid.Parent).PlayerGui:Destroy() end end end)
Thanks in advance.
You have made one wrong error, I'll rewrite the script and show you where you have gone wrong
local vehicleseat = script.Parent local GUI = script.DeleteGUI script.Parent.Changed:connect(function(property) if property == "Occupant" then local humanoid = vehicleseat.Occupant if humanoid then GUI:clone().Parent = game.Players:GetPlayerfromcharacter(humanoid.Parent):WaitForChild("PlayerGui") else -- before, you were removing the playergui not the deletegui game.Players:GetPlayerFromCharacter(humanoid.Parent).PlayerGui.DeleteGui.Destroy() end end end)
Hope this helps! ~tantec
On line 8 you said GetPlayerfromcharacter
. Remember that capitalization matters. Change it to GetPlayerFromCharacter
like you have it on line 10.
Also connect
is deprecated. Change it to Connect
.
Hope this helps! :)