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
|
  |
| Joined: 03 Nov 2014 |
| Total Posts: 844 |
|
| |
|
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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 03 Nov 2014 |
| Total Posts: 844 |
|
|
| 27 Aug 2016 09:17 AM |
| is that what the script above does? |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2016 09:17 AM |
as long as you see ' gui:Clone().Parent = PlayerVariable.PlayerGui |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|