VXAP
|
  |
| Joined: 01 Aug 2016 |
| Total Posts: 28 |
|
|
| 23 Aug 2016 05:33 PM |
hi guys so I am making a game and I made a brick with a local script the idea is that when you touch the brick it opens the GUI yet I don't seem to find the problem LOCAL SCRIPT:
Local plr = game.Players.LocalPlayer local part = Script.Parent part.Touched:connect(function(hit) local humanoid = hit:FindFirstChild("Humanoid") if humanoid ~= nil then game.ServerStorage.ShopGUI:Clone().Parent = player.PlayerGui end end end) end)
pretty basic yet I can't find the problem any help? maybe I messed up? I put the GUI in SeverStorage and it's named ShopGUI the script is in the brick any help plz?
|
|
|
| Report Abuse |
|
|
12904
|
  |
| Joined: 29 Oct 2012 |
| Total Posts: 441 |
|
|
| 23 Aug 2016 05:42 PM |
| Touched functions don't work in local scripts. |
|
|
| Report Abuse |
|
|
|
| 23 Aug 2016 05:48 PM |
Touched very much works in a local script.
part = Script.Parent, should be part = script.Parent.
Caps sensitive. |
|
|
| Report Abuse |
|
|
VXAP
|
  |
| Joined: 01 Aug 2016 |
| Total Posts: 28 |
|
|
| 24 Aug 2016 03:02 AM |
so the script is this: local player = game.Players.LocalPlayer local part = script.Parent part.Touched:connect(function(hit) local humanoid = hit:FindFirstChild("Humanoid") if humanoid ~= nil then game.ServerStorage.ShopGUI:Clone().Parent = player.PlayerGui end end end)
yet the GUI doesn't shop up even tho I tested it
|
|
|
| Report Abuse |
|
|
|
| 24 Aug 2016 03:57 AM |
| you didnt call the function |
|
|
| Report Abuse |
|
|
VXAP
|
  |
| Joined: 01 Aug 2016 |
| Total Posts: 28 |
|
|
| 24 Aug 2016 04:18 AM |
meanwhile I written a new one and I keep failing anyhelp? XD
local Gui = game.Lighting.ShopGUI
function GiveGui(Player) if Player.PlayerGui:FindFirstChild(Gui.GUI)~= nil then return end Gui:Clone().Parent=Player.PlayerGui end
script.Parent.Touched:connect(function(hit)
local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if Player == nil then return end GiveGui(Player)
end)
|
|
|
| Report Abuse |
|
|
VXAP
|
  |
| Joined: 01 Aug 2016 |
| Total Posts: 28 |
|
|
| 24 Aug 2016 04:37 AM |
Fixed it, changed it to normal script
function touch(part) if game.Players:FindFirstChild(part.Parent.Name) then if game.Players:FindFirstChild(part.Parent.Name).PlayerGui:FindFirstChild("ShopGui") == nil then gui = Instance.new("ScreenGui") gui = game.Lighting.ShopGUI:clone() gui.Name = "ShopGUI" gui.Parent = game.Players:FindFirstChild(part.Parent.Name).PlayerGui end end end script.Parent.Touched:connect(touch)
change "ShopGUI" to the name of your GUI in both gui.Name and gui = game.Lighting Put the GUI in Lighting and then just touch it and boom! thanks for anyone responding <3
|
|
|
| Report Abuse |
|
|
|
| 24 Aug 2016 05:40 AM |
If you want something local, why go through the trouble of re-configuring it, just make the brick itself local to that player.
|
|
|
| Report Abuse |
|
|