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 » Scripting Helpers
Home Search
 

Re: Question

Previous Thread :: Next Thread 
wilson1212 is not online. wilson1212
Joined: 22 Mar 2010
Total Posts: 1033
25 Jul 2012 04:19 PM
Where would I change the position of the projectile in the script?



-- 42672473 is sorry sound
-- 42672581 is wind-knocked-out sound

ball = script.Parent
damage = 10

HitSound = Instance.new("Sound")
HitSound.Name = "HitSound"
HitSound.SoundId = "http://www.roblox.com/asset/?id=11945266"
HitSound.Parent = ball
HitSound.Volume = 1

PersonHitSound = Instance.new("Sound")
PersonHitSound.Name = "PersonHitSound"
PersonHitSound.SoundId = "http://www.roblox.com/asset/?id=42672473"
--PersonHitSound.SoundId = "http://www.roblox.com/asset/?id=42672581" -- grunt sound
PersonHitSound.Volume = .5
PersonHitSound.Pitch = 1
PersonHitSound.Parent = ball

function onTouched(hit)
local humanoid = hit.Parent:findFirstChild("Humanoid")

if humanoid ~= nil then
tagHumanoid(humanoid)
humanoid:TakeDamage(damage)
untagHumanoid(humanoid)

soundSelector = math.random()*100
PersonHitSound:Play()
ball.Parent = nil
else
HitSound:Play()
end
end

function tagHumanoid(humanoid)
-- todo: make tag expire
local tag = ball:findFirstChild("creator")
if tag ~= nil then
local new_tag = tag:clone()
new_tag.Parent = humanoid
end
end


function untagHumanoid(humanoid)
if humanoid ~= nil then
local tag = humanoid:findFirstChild("creator")
if tag ~= nil then
tag.Parent = nil
end
end
end

connection = ball.Touched:connect(onTouched)

wait(5)
--ball.SparkSound.Looped = false
--ball.SparkSound:Stop()
ball.Parent = nil
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
25 Jul 2012 04:28 PM
The projectile is probably positioned by a different script. This one doesn't affect the projectile until it's hit or 5 seconds has elapsed.
Report Abuse
wilson1212 is not online. wilson1212
Joined: 22 Mar 2010
Total Posts: 1033
25 Jul 2012 04:42 PM
My bad, is this the right script?


local Tool = script.Parent;

enabled = true

--local spark = Instance.new("Sparkles")
--spark.Color = Color3.new(0,1,0)

function fire(v)

local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)

local missile = Instance.new("Part")


--spark:Clone().Parent = missile

local spawnPos = vCharacter.PrimaryPart.Position

local PewPew = Tool.Handle:FindFirstChild("PewPew")

if (PewPew == nil) then
PewPew = Instance.new("Sound")
PewPew.Name = "PewPew"
PewPew.SoundId = "http://www.roblox.com/asset/?id=26618834"
PewPew.Parent = Tool.Handle
PewPew.Volume = .2
PewPew.Pitch = 1.2
end


spawnPos = spawnPos + (v * 10)


missile.Position = spawnPos
missile.Size = Vector3.new(.2,.2,.2)
missile.Velocity = v * 750
missile.BrickColor = BrickColor.new("Lime Green")
missile.Shape = 0
missile.BottomSurface = 0
missile.TopSurface = 0
missile.Name = "Spark"
missile.Reflectance = .5
missile.Elasticity = 1


local force = Instance.new("BodyForce")
force.force = Vector3.new(0,98,0)
force.Parent = missile

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

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

--Tool.Handle.GruntSound:Clone().Parent = missile

missile.Parent = game.Workspace

PewPew:Play()
-- wait(.15)
--PewPew:Stop()
end



function gunUp()
Tool.GripForward = Vector3.new(0,.981,-.196)
Tool.GripRight = Vector3.new(1,0,0)
Tool.GripUp = Vector3.new(0,.196,.981)
end

function gunOut()
Tool.GripForward = Vector3.new(0,1,0)
Tool.GripRight = Vector3.new(1,0,0)
Tool.GripUp = Vector3.new(0,0,1)
end

function isTurbo(character)
return character:FindFirstChild("BoltHelm") ~= nil
end


function onActivated()
if not enabled then
return
end

enabled = false


local character = Tool.Parent;
local humanoid = character.Humanoid
if humanoid == nil then
print("Humanoid not found")
return
end

local targetPos = humanoid.TargetPoint
local lookAt = (targetPos - character.Head.Position).unit

local reload = .1
--if (isTurbo(character)) then
-- reload = .25
-- print("turbo")
--end

gunUp()
fire(lookAt)
wait(reload)
gunOut()
wait(reload)

enabled = true

end

function onEquipped()
--Tool.Handle.EquipSound:play()
end

script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
25 Jul 2012 04:45 PM
"local spawnPos = vCharacter.PrimaryPart.Position

local PewPew = Tool.Handle:FindFirstChild("PewPew")

if (PewPew == nil) then
PewPew = Instance.new("Sound")
PewPew.Name = "PewPew"
PewPew.SoundId = "http://www.roblox.com/asset/?id=26618834"
PewPew.Parent = Tool.Handle
PewPew.Volume = .2
PewPew.Pitch = 1.2
end


spawnPos = spawnPos + (v * 10)"

You would change the following two lines:
local spawnPos = vCharacter.PrimaryPart.Position -- This is the character's head, if you aren't aware
spawnPos = spawnPos + (v * 10)
Report Abuse
wilson1212 is not online. wilson1212
Joined: 22 Mar 2010
Total Posts: 1033
25 Jul 2012 04:47 PM
Thanks :D
Report Abuse
wilson1212 is not online. wilson1212
Joined: 22 Mar 2010
Total Posts: 1033
25 Jul 2012 04:57 PM
What would I change the "primarypart" to if I wanted the right arm?
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
25 Jul 2012 04:58 PM
local spawnPos = vCharacter["Right Arm"].Position
Report Abuse
wilson1212 is not online. wilson1212
Joined: 22 Mar 2010
Total Posts: 1033
25 Jul 2012 05:08 PM
Changing the spawn position to the right arm broke the script, I guess I'll keep the position at the head.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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