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

gui pop up script from brick wont work but no errors?

Asked by
3wdo 198
4 years ago

so someone helped me with this last night and it worked but now it just wont work anymore. the script is not disabled and i dont know what the problem is

script.Parent.Touched:Connect(function(hit)
    local Player = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent)
    if Player then
        Player:WaitForChild('PlayerGui'):WaitForChild('Tips').Enabled = true
print(Player.name.." Hit The Brick")
    end
end)

1 answer

Log in to vote
2
Answered by
sheepposu 561 Moderation Voter
4 years ago
Edited 4 years ago

The script looks good from a quick scan over it, so I have an assumption as to why it may not work. Sometimes, you can get something that's not one of the main body parts to hit something, and the character from that part is not just hit.Parent. So try out this script.

script.Parent.Touched:Connect(function(hit)
    local hum = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid") --One of them will be valid, otherwise it is not a player
    if hum ~= nil then
        local Player = game:GetService('Players'):GetPlayerFromCharacter(hum.Parent)
            if Player then
            Player:WaitForChild('PlayerGui'):WaitForChild('Tips').Enabled = true
                print(Player.name.." Hit The Brick")
        end
    end
end)

Hope this helps

Ad

Answer this question