Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make this sign show who is sitting in a specific seat?

I'm trying to make a sign say who is sitting in a seat. This is the explorer page http://prntscr.com/rkf9ve

This is the script that's in Model.Script

while true do
	wait(0.1)
	script.Parent.Value.Value = "".." script.Parent.Seat.Occupant"
end

And here's the script that's in Screen.SurfaceGUI.ECGValue.Script

while true do
	wait(0.1)
	script.Parent.Text = "PATIENT: "..script.Parent.Parent.Parent.Parent.Value.Value..""
end

I honestly don't know what to do anymore, I am new to this and I'm trying to learn.

Please help me if you have any idea on how to make this work

1 comment

0

DominicMrKiwi#6864 if you need me. I'm going to check this in the morning, sorry.

1 answer

Okay so, you're doing it right, the problem is that you are putting script.Parent.Seat.Occupant INTO the string and you didn't escape it, so you have to escape it.

while true do
    wait(0.1)
    script.Parent.Value.Value = script.Parent.Seat.Occupant
end

So that should be it right? Well, no, EGGValue.Script will error, why? It will error because you're concatening an userdata, so you have to use.Name

while true do
    wait(0.1)
    script.Parent.Value.Value = script.Parent.Seat.Occupant.Name
end

Done! Or is it? Now it works, but the problem is that it may say "Humanoid", am i right? That's because when you seat the Occupant property is going to be the humanoid of the character so you'll have to use .Parent on it

while true do
    wait(0.1)
    script.Parent.Value.Value = script.Parent.Seat.Occupant.Parent.Name
end

But it can be nil too! In this case we have to make another variable called OccupantName, if it doesn't find an occupant it'll be changed to ""

So this is the final code

while true do
    wait(0.1)
local OccupantName = script.Parent.Seat.Occupant or ""
if OccupantName ~= "" then
OccupantName = OccupantName.Parent.Name
end
    script.Parent.Value.Value = OccupantName
end

If this helped, mark this as the answer!

2 comments

0

It still doesn't work. Thank you for trying but I really don't know what's going on with it. Please contact me on discord if you could still somehow help me. DominicMrKiwi#6864

0

@DominicMrKIwi there

This discussion is preserved as it was. New answers, comments, and votes are closed.