Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to make a player detecting seat?

Asked by 7 years ago

Trying to create a seat that when a player sits on it, it shows them a special gui, let's call it an control gui.

I've tried this but I don't know how to make it detect which player is sitting on it and to make it fire for the certain player:

Seat = script.Parent

function fireThis()
game.StarterGui.ScreenGui.Frame.Visible = false
end


Seat.Changed:connect(function(property)
if property == "Occupant" then
fireThis()
end
end)

Any help would be appreciated! Thanks Light

1 answer

Log in to vote
0
Answered by
itsJooJoo 195
7 years ago
Edited 7 years ago

Problem

You can't detect the player

Solution

Use a .Touched function to detect a player that touched it

Suggestions

The variable is only used once, so remove that and type that itself. You are making the frame disappear by changing the property to false, make it true. Remove the function, as you only use it once. And take away the .Changed function. In a sense, I'm redoing this entire script. Tweening is a much more clean option, you can look into that here.

Final Script

script.Parent.Touched:connect(function(hit)
    local hum = hit.Parent:FindFirstChild("Humanoid")
    if hum then
        local plr = game.Players:FindFirstChild(hit.Parent.Name)
        if plr then
            plr.PlayerGui.ScreenGui.Frame.Visible = true
        end
    end
end)

Remember, if this helped, be sure to hit that accept button; it helps us both!

Ad

Answer this question