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

I'm trying to show a frame on screen for 1 second, why wont it work?

Asked by 3 years ago
Edited 3 years ago

I'm a beginner so help would be appreciated :) My script:

Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
      if humanoid == nil then return end
    frame.Enabled = true
    wait(1)
    frame.Enabled = false
end)

1 answer

Log in to vote
0
Answered by
imKirda 4491 Moderation Voter Community Moderator
3 years ago

Have you define humanoid and frame? If so then please show them if not then here is what you have to do:

Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
    local humanoid = Seat.Occupant -- This is the humanoid of player sitting on the seat
    local character = humanoid.Parent -- We need character to get player, character is humanoid's parent
    local player = game:GetService("Players"):GetPlayerFromCharacter(character) -- Function that gets the player from character, we need it to access player gui
    local player_gui = player:WaitForChild("PlayerGui") -- All the guis that player sees are inside of this instance, next we need to access the frame
    local frame = player_gui:WaitForChild("FrameName") -- If you want to clone the frame then use :Clone() function

         if humanoid == nil then return end
        frame.Visible = true -- Sets the frame and all it's descendants not visible
        wait(1)
        frame.Visible= false -- Sets the frame and all it's descendants visible
    end)

I hope you understood, i tried to explain from what i've seen in your script but i am not sure what you are trying to achieve and where is the error but this should work.

0
Thanks Script_Summary 13 — 3y
0
Also put the if humanoid == nil before line 2 and you forgot to put end before end), sorry i forgot imKirda 4491 — 3y
0
Also put the if humanoid == nil before line 2 and you forgot to put end before end), sorry i forgot imKirda 4491 — 3y
Ad

Answer this question