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: GUI Button help

Previous Thread :: Next Thread 
Dreaderr is not online. Dreaderr
Joined: 03 Nov 2014
Total Posts: 844
24 Aug 2016 07:16 PM
i have no clue how to work with guis at all

how would this code be transformed form a click detecter to a button GUI that comes up when you sit in a seat?

[


local switch = script.Parent
local gunBarrelOne = script.Parent.Parent.GunBarrel.One

local debounce = false
local gunOne = true

local cannonBall = Instance.new("Part")
cannonBall.Size = Vector3.new(1,1,1)
cannonBall.BrickColor = BrickColor.new(1) -- medium blue
cannonBall.Shape = 0
cannonBall.BottomSurface = 0
cannonBall.TopSurface = 0
cannonBall.Name = "Cannon Shot"
cannonBall.Elasticity = .1
cannonBall.Reflectance = 0
cannonBall.Friction = 0

function fire(player)

local sound = script.Parent:findFirstChild("GunSound")
if sound == nil then
sound = Instance.new("Sound")
sound.Name = "GunSound"
sound.SoundId = "http://www.roblox.com/asset?id=2101148"
sound.Volume = 1
sound.Parent = script.Parent
end
sound:play()




local missile = Instance.new("Part")


local barrel

if gunOne == true then
barrel = gunBarrelOne
gunOne = true

end

local spawnPos = barrel.CFrame * Vector3.new(5, 0, 0)

local dx = math.random(50,50)
local dy = math.random(0,0)
local dz = math.random(0,0)
local mag = math.random(750,750)

local v = barrel.CFrame:vectorToWorldSpace(Vector3.new(mag + dx,dy,dz))

local missile = cannonBall:clone()

missile.Position = spawnPos
missile.Velocity = v



local new_script = script.Parent.CannonBall:clone()
new_script.Disabled = false
new_script.Parent = missile

local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = player
creator_tag.Name = "creator"
creator_tag.Parent = missile



missile.Parent = game.Workspace

end

function onClicked()
if debounce == false then
debounce = true
switch.BrickColor = BrickColor.new(21)
-- let slip the dogs of war
fire(player)
wait(.5)

wait(1)
debounce = false
switch.BrickColor = BrickColor.new(37)
end
end


script.Parent.ClickDetector.MouseClick:connect(onClicked)


]
Report Abuse
Dreaderr is not online. Dreaderr
Joined: 03 Nov 2014
Total Posts: 844
25 Aug 2016 06:20 AM
bump
Report Abuse
JoshRBX is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
25 Aug 2016 07:13 AM
local switch = script.Parent
local gunBarrelOne = script.Parent.Parent.GunBarrel.One

local debounce = false
local gunOne = true

local cannonBall = Instance.new("Part")
cannonBall.Size = Vector3.new(1,1,1)
cannonBall.BrickColor = BrickColor.new(1) -- medium blue
cannonBall.Shape = 0
cannonBall.BottomSurface = 0
cannonBall.TopSurface = 0
cannonBall.Name = "Cannon Shot"
cannonBall.Elasticity = .1
cannonBall.Reflectance = 0
cannonBall.Friction = 0

function fire(player)

local sound = script.Parent:findFirstChild("GunSound")
if sound == nil then
sound = Instance.new("Sound")
sound.Name = "GunSound"
sound.SoundId = "http://www.roblox.com/asset?id=2101148"
sound.Volume = 1
sound.Parent = script.Parent
end
sound:play()




local missile = Instance.new("Part")


local barrel

if gunOne == true then
barrel = gunBarrelOne
gunOne = true

end

local spawnPos = barrel.CFrame * Vector3.new(5, 0, 0)

local dx = math.random(50,50)
local dy = math.random(0,0)
local dz = math.random(0,0)
local mag = math.random(750,750)

local v = barrel.CFrame:vectorToWorldSpace(Vector3.new(mag + dx,dy,dz))

local missile = cannonBall:clone()

missile.Position = spawnPos
missile.Velocity = v



local new_script = script.Parent.CannonBall:clone()
new_script.Disabled = false
new_script.Parent = missile

local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = player
creator_tag.Name = "creator"
creator_tag.Parent = missile



missile.Parent = game.Workspace

end

function onClicked()
if debounce == false then
debounce = true
switch.BrickColor = BrickColor.new(21)
-- let slip the dogs of war
fire(player)
wait(.5)

wait(1)
debounce = false
switch.BrickColor = BrickColor.new(37)
end
end


script.Parent.MouseButton1Click:connect(onClicked)


- 𝑱𝒐𝒔𝒉𝑹𝑩𝑿 -
Report Abuse
Dreaderr is not online. Dreaderr
Joined: 03 Nov 2014
Total Posts: 844
27 Aug 2016 09:05 AM
@above welp i did some testing and the cannon is not firing now..what do i do?
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
27 Aug 2016 09:07 AM
clickdetectors will give you the player who clicked on mouseclick

just use mouseclick and throw the gui in them
Report Abuse
Dreaderr is not online. Dreaderr
Joined: 03 Nov 2014
Total Posts: 844
27 Aug 2016 09:17 AM
is that what the script above does?
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
27 Aug 2016 09:17 AM
as long as you see
'
gui:Clone().Parent = PlayerVariable.PlayerGui
Report Abuse
Dreaderr is not online. Dreaderr
Joined: 03 Nov 2014
Total Posts: 844
27 Aug 2016 09:20 AM
its not there..were do i place it in the script?
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
27 Aug 2016 09:24 AM
you need to put local scripts in the Gui to fire the cannon and make the server script only clone the Gui onto them

because ServerScripts cant connect functions to gui events that require user input like clicking and typing
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