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
5 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

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

1 answer

Log in to vote
2
Answered by
sheepposu 561 Moderation Voter
5 years ago
Edited 5 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.

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

Hope this helps

Ad

Answer this question