generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: On Touch Scripting error

Previous Thread :: Next Thread 
VXAP is not online. 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 is not online. 12904
Joined: 29 Oct 2012
Total Posts: 441
23 Aug 2016 05:42 PM
Touched functions don't work in local scripts.
Report Abuse
KillerKyle is not online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
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 is not online. 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
DivisionTalk is not online. DivisionTalk
Joined: 29 Jul 2011
Total Posts: 562
24 Aug 2016 03:57 AM
you didnt call the function
Report Abuse
VXAP is not online. 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 is not online. 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
CrixusOdalisManiatus is online. CrixusOdalisManiatus
Joined: 16 Jun 2011
Total Posts: 5987
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image