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

When part touched gui pops up not working?

Asked by 4 years ago

here is the script - it is in a local script in the part that is being touched

local player = game.Players.LocalPlayer

script.Parent.Touched:Connect(function()
    player.PlayerGui.Win.Enabled = true
end)

4 answers

Log in to vote
0
Answered by 4 years ago

Normal script inside part:

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:WaitForChild("Humanoid") then
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        plr.PlayerGui.Win.Enabled = true
    end
end)

I used a normal script here because local scripts only work in ReplicatedStorage, StarterGui and StarterPlayer.

0
yes that works :) TabooAntonioiscool 42 — 4y
0
Could you please accept this as an answer then? PrismaticFruits 842 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I am not sure if your way is correct, this is my way how to do it

script.Parent.Touched:Connect(function(Hit) -- The hit object called HIt
if Hit.Parent:FindFirstChild("Humanoid") then -- IT IS A PLAYER ! DO SOMETHING!
    local Player = Hit.Parent:GetPlayerFromCharacter(Hit.Parent)
    Player.PlayerGui.Win.Enabled = true
    end
end)
0
Wrong. PrismaticFruits 842 — 4y
0
Line 3 is wrong. Use mine(the one below this). PrismaticFruits 842 — 4y
0
Welp fixed it lol Nguyenlegiahung 1091 — 4y
Log in to vote
0
Answered by 4 years ago

it didn't work. I changed the script to a normal script but still didn't work...

Log in to vote
0
Answered by 4 years ago

Keep it in the LocalScript. I'm assuming you renamed your ScreenGui to Win. You may want to try this method:

local Gui = game.StarterGui.Win.ImageButton -- If there's not an ImageButton, then change it to whatever it is inside of Win. ImageButton was just an example, but keep it if it's actually an ImageButton that a player is looking at.

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        if Gui.Visible = false then
            Gui.Visible = true
        end
    end
end)

Hope this helps!

Answer this question