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?
Assuming "holding an item" means "with a tool equipped" then you can do this (putting the script in the part they walk on)
01 | local toolname = "Sword" -- What they should be holding when stepping on the part |
02 |
03 | script.Parent.Touched:connect( function (hit) |
04 | if hit.Parent then |
05 | local player = Game.Players:GetPlayerFromCharacter(hit.Parent) |
06 | if player then |
07 | if player.Character:FindFirstChild(toolname) then |
08 | -- make the GUI show |
09 | -- try putting the GUI you want to show up in ReplicatedStorage then inserting it into the player's PlayerGui here |
10 | end |
11 | end |
12 | end |
13 | end ) |
Try this
01 | function onTouch() |
02 | Tool = game.Starterpack.Toolname --Change toolname to the name of the tool |
03 | if Tool.Equipped = = true then |
04 | if Player.Touched = = true then |
05 | if guiname.Visible = = false then -- replace guiname with the name of the gui |
06 | wait( 0.5 ) |
07 | guiname.Visible = true |
08 | end |
09 | onTouch:connect |
10 | end |
11 | onTouch() |
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?