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

GUI Pop-Up [closed]

Asked by 10 years ago

I’m having difficulty creating a script, where if you walk onto a certain part, holding an item, a GUI will pop up. Anybody able to help me?

Locked by FearMeIAmLag and BlueTaslem

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
5
Answered by
MrNicNac 855 Moderation Voter
10 years ago

Assuming "holding an item" means "with a tool equipped" then you can do this (putting the script in the part they walk on)

local toolname = "Sword" -- What they should be holding when stepping on the part

script.Parent.Touched:connect( function(hit)
    if hit.Parent then
        local player = Game.Players:GetPlayerFromCharacter(hit.Parent)
        if player then
            if player.Character:FindFirstChild(toolname) then
                -- make the GUI show 
                -- try putting the GUI you want to show up in ReplicatedStorage then inserting it into the player's PlayerGui here
            end
        end
    end
end)
1
You might also include a check to make sure that child is actually a tool. Bubby4j 231 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

Try this

function onTouch()
Tool  = game.Starterpack.Toolname --Change toolname to the name of the tool
if Tool.Equipped == true then
if Player.Touched == true then
if guiname.Visible == false then -- replace guiname with the name of the gui
wait(0.5)
guiname.Visible = true
end
onTouch:connect
end
onTouch()