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 » Game Design
Home Search
 

Re: Need help

Previous Thread :: Next Thread 
bobaliny2 is not online. bobaliny2
Joined: 12 May 2009
Total Posts: 97
16 Mar 2014 12:21 AM
In my game, I coded a sniper, and in the test mode for studio it works, but when I go to hit the 'Play' button of the game, the gun refuses to shoot or do anything. Any ideas?

Here is the script.

local tool = script.Parent
local user


function postion(a, v, t, x)
return .5*a*t^2 + v*t + x
end

tool.Equipped:connect(function(mouse)
user = tool.Parent

mouse.Button1Down:connect(function()
local part = Instance.new("Part", user)
part.Name = "RepresentingPart"
part.FormFactor = "Custom"
part.Size= Vector3.new(0.5,0.5,0.5)
part.BrickColor = BrickColor.new("Really Black")
part.Anchored = true
part.CanCollide = false

local speed = 500
local gravity = Vector3.new(0,-32,0)
local direction = (mouse.Hit.p - user.Head.Position).unit
local initVelocity = speed*direction

local t = tick()
local startingTime = t
local hit = nil
local hitpos = nil
local lastPos = user.Head.Position

while not hit and t-startingTime < 3 do
local pos = postion(gravity, initVelocity, t-startingTime, user.Head.Position)
part.CFrame = CFrame.new(pos)
hit, hitpos = workspace:FindPartOnRay(Ray.new(lastPos, (pos-lastPos).unit*(pos-lastPos).magnitude), user)
wait()
t = tick()
lastPos = pos
end

if hit then
breakable = hit:FindFirstChild("isBreakable")
hitVal = hit:FindFirstChild("numHit")
if breakable ~= nil and breakable.Value == true then
if hitVal.Value == 2 then
hit:Destroy()
part:Destroy()
return
end
if hitVal.Value == 1 then
hit.Material = "Ice"
hitVal.Value = 2
end
if hitVal.Value == 0 then
hitVal.Value = 1
end
end
if hit.Parent:FindFirstChild("Health") ~= nil then
local found = hit.Parent:FindFirstChild("Humanoid")
local damage = 100
if found ~= nil then
found.Health = found.Health - damage
end
end
end

part:Destroy()

end)
end)
Report Abuse
Blackstride is not online. Blackstride
Joined: 19 Nov 2010
Total Posts: 8133
16 Mar 2014 11:58 AM
Give this script to Scripting Helpers.
Report Abuse
georgeba is not online. georgeba
Joined: 29 Oct 2011
Total Posts: 1092
17 Mar 2014 12:41 PM
Hi There! This is the wrong forum, I would suggest going to scripting helpers forum. You would probably get a lot more replies there.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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