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

Why isnt it when I touch the Block a GUI won't pop-up?

Asked by 6 years ago
local hitpart = script.Parent
local function onclick(click)
    local h = click.Parent:FindFirstChild("Humanoid")
    if h then
        print('it works')
        local player = game.Players:GetPlayerFromCharacter(click.Parent)
    player.PlayerGui.Song.Frame.Visible = true
    end
end
hitpart.ClickDetector.MouseClick:connect(onclick)

Please help explain where I went wrong.

1 answer

Log in to vote
0
Answered by
yyyyyy09 246 Moderation Voter
6 years ago
Edited 6 years ago
local hitpart = script.Parent

local function onclick(player)

    print("It Works")
    player.PlayerGui.Song.Frame.Visible = true

end

hitpart.ClickDetector.MouseClick:connect(onclick)

The MouseClick event returns the player, not the character. Hope this helps

0
My thing though is why does it find a player why couldn't I just use the script i made since it works if it's a ontouch function duckyo011 36 — 6y
Ad

Answer this question