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: How to check a object name when hit by a bullet

Previous Thread :: Next Thread 
MilkyWay01 is not online. MilkyWay01
Joined: 22 Feb 2010
Total Posts: 1049
30 Apr 2011 09:39 PM
When this bullet (spell) hits an object I want it to only to make the object trip if the object is called Dementor. I think the script I need is similar to VIP scripts checking for shirts, but other than that I have no idea. My spell works on the Dementor and a robloxian as it is.

local wand = script.Parent
local stick = wand.Handle
local inc = script.Name
local owner, connect

function SpellAffect(hit,spell) if (not hit.CanCollide) and (hit.Parent.:findFirstChild("Humanoid") == nil) then return end <---I think you would check the hit.Parent name around here
local hum = hit.Parent.:findFirstChild("Humanoid")
if (hum) then
hum.Sit = true <------------here is where the object trips
end
spell:Remove()
end

function Setup()
for i,p in pairs(game.Players:children()) do
if (p.Character == wand.Parent) then
print("Found owner of wand!")
if (connect ~= nil) then connect:disconnect() end
connect = p.Chatted:connect(PlayerTalked)
owner = p
end
end
end

function PlayerTalked(words)
print("Someone talked!")
if (string.find(words:lower(), inc:lower()) ~= nil) and (wand.Parent == owner.Character) then
print("Casting the spell ''" ..inc.. "''")
CastSpell()
end
end

function CastSpell()
local p = Instance.new("Part")
p.formFactor = "Symmetric"
p.Shape = "Ball"
p.Size = Vector3.new(1,1,1)
p.TopSurface = "Smooth"
p.BottomSurface = "Smooth"
p.Transparency = 0.5
p.BrickColor = script.SpellColor.Value
local Fire = Instance.new("Fire")
Fire.Color = script.FireColor.Value
Fire.SecondaryColor = script.FireColor.Value
Fire.Enabled = script.HasSparkles.Value
Fire.Parent = p
local sparx = Instance.new("Sparkles")
sparx.SparkleColor = script.SparkColor.Value
sparx.Enabled = script.HasSparkles.Value
sparx.Parent = p
local sparx2 = Instance.new("Sparkles")
sparx2.SparkleColor = script.SparkColor.Value
sparx2.Enabled = script.HasSparkles.Value
sparx2.Parent = p
local sparx3 = Instance.new("Sparkles")
sparx3.SparkleColor = script.SparkColor.Value
sparx3.Enabled = script.HasSparkles.Value
sparx3.Parent = p
local sparx4 = Instance.new("Sparkles")
sparx4.SparkleColor = script.SparkColor.Value
sparx4.Enabled = script.HasSparkles.Value
sparx4.Parent = p
coroutine.resume(coroutine.create(function()
wait(10)
p:Remove()
end))
local bv = Instance.new("BodyVelocity")
p.Parent = workspace
p.Name = "MagicSpell"
p.CFrame = stick.CFrame * CFrame.new(0,1.5,0)
bv.Parent = p
bv.velocity = ((owner.Character.Humanoid.TargetPoint - p.Position).unit) * 200
p.Touched:connect(function(part)
SpellAffect(part,p)
end)
end

wand.Equipped:connect(Setup)
Report Abuse
TheNewFissy is not online. TheNewFissy
Joined: 03 Jan 2011
Total Posts: 1301
30 Apr 2011 09:41 PM
-- If you made the script above, you should be able to add this in.

if Object.Name == "Dementor" then

end
Report Abuse
Ronnie124 is not online. Ronnie124
Joined: 26 Nov 2009
Total Posts: 694
30 Apr 2011 09:42 PM
if (Object.Parent:findFirstChild("Humanoid")) then
Object.Parent:findFirstChild("Humanoid").PlatformStand = true
end
Report Abuse
TheNewFissy is not online. TheNewFissy
Joined: 03 Jan 2011
Total Posts: 1301
30 Apr 2011 09:43 PM
Wouldn't that just disable the humanoid?
Report Abuse
MilkyWay01 is not online. MilkyWay01
Joined: 22 Feb 2010
Total Posts: 1049
30 Apr 2011 09:48 PM
ronnie are you sure that will work?
It just changes the sit part to a platform stand. that has nothing to do with the dementor stuff
Report Abuse
MilkyWay01 is not online. MilkyWay01
Joined: 22 Feb 2010
Total Posts: 1049
30 Apr 2011 09:59 PM
Oh yeah, thanks for your first post New, I changed it a little but I kept most of it
Report Abuse
MilkyWay01 is not online. MilkyWay01
Joined: 22 Feb 2010
Total Posts: 1049
30 Apr 2011 10:14 PM
Nevermind I was wrong. I changed it but it still works on the dementor and me, I just tested it on the dementor first. Here is the new script but it is shorter because I'm just posting the one paragraph.

local wand = script.Parent
local stick = wand.Handle
local inc = script.Name
local owner, connect

function SpellAffect(hit,spell)
if hit.Name ~= "Dementor" then
end
if (not hit.CanCollide) and (hit.Parent:findFirstChild("Humanoid") == nil) then return end
local hum = hit.Parent:findFirstChild("Humanoid")
if (hum) then
hum.PlatformStand = true
hum.WalkSpeed = 0
wait (2)
hum.WalkSpeed = 16
wait (2)
hum.PlatformStand = false
end
spell:Remove()
end


This freezes and platformstands both robloxians and dementors
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