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: preventing my self from getting damaged

Previous Thread :: Next Thread 
FearlessCrossFire is not online. FearlessCrossFire
Joined: 07 Feb 2012
Total Posts: 138
31 Oct 2014 01:43 AM
how do i prevent myself from getting damaged?

i have a script that summons a lava brick that hurts anyone when they touch it

but how do i make myself not get damaged from touching it??

any help?
Report Abuse
zaniac10 is online. zaniac10
Joined: 18 Aug 2009
Total Posts: 10000
31 Oct 2014 02:18 AM
can you give us your code?
Report Abuse
zaniac10 is online. zaniac10
Joined: 18 Aug 2009
Total Posts: 10000
31 Oct 2014 02:23 AM
if your code has hit as the function it would be like this

if hit.Parent.Name == "YourName" then return; end
Report Abuse
Mironinja4 is not online. Mironinja4
Joined: 23 Nov 2013
Total Posts: 45
31 Oct 2014 02:28 AM
Does it kill instantly? I have 2 options:

Solution 1:
*SCRIPT IN WORKSPACE*

local players = game:Players

while true do
if players:findFirstChild("FearlessCrossFire") then
local player = "FearlessCrossFire"
end
game.Workspace:findFirstChild(player) then -- or "Crossfire"
humanoid = game.Workspace.Crossfire.Humanoid
if humanoid.Health ~= 100 then
humanoid.Health = 100
end
wait()
end




Solution 2, which is VEEEERY simple.

*THE REMADE SCRIPT OF THE LAVA BRICK*

function onTouched(part)
if part.Parent:findFirstChild("Humanoid") then
if part.Parent.Name ~= "FearlessCrossFire" then
part.Parent.Humanoid.Health = 0
end
end

end

game.Workspace.Lava.Touched:connect(onTouched())

Report Abuse
WishNite is not online. WishNite
Joined: 11 Feb 2009
Total Posts: 15828
31 Oct 2014 02:33 AM
or... in a localscript with FE disabled

repeat wait() until game.Players.LocalPlayer.Character
if game.Players.LocalPlayer.Name == "whateveryournameisidunno" then
game.Players.LocalPlayer.Character.Humanoid.Changed:connect(function()
game.Players.LocalPlayer.Character.Humanoid.Health = 100
end)
end
Report Abuse
Mironinja4 is not online. Mironinja4
Joined: 23 Nov 2013
Total Posts: 45
31 Oct 2014 02:59 AM
But what if he dies instantly?
Report Abuse
FearlessCrossFire is not online. FearlessCrossFire
Joined: 07 Feb 2012
Total Posts: 138
31 Oct 2014 06:11 AM
thanks for the help!but what about finding the caster's name and print it when he summons the brick and applying that so he doesn't get damaged by the lava brick when he touches it.(it should be a localscript and it's parent is a hopperbin)
its just like a trap.when a player sets the trap(lava brick)he shoudnt be hurt by his own trap but other players gets damaged.
Report Abuse
FearlessCrossFire is not online. FearlessCrossFire
Joined: 07 Feb 2012
Total Posts: 138
31 Oct 2014 06:15 AM
every player has the tool.if the player summons the brick he shoudnt be hurt by his own.but if he touches other's lava brick then he should be hurt
Report Abuse
Mironinja4 is not online. Mironinja4
Joined: 23 Nov 2013
Total Posts: 45
01 Nov 2014 05:11 AM
Then make a string value inside each brick that is summoned with the creator's name in it, or even a table, then a script that detects whenever the player that touched is the creator, if he is not, kill him.
Report Abuse
Mironinja4 is not online. Mironinja4
Joined: 23 Nov 2013
Total Posts: 45
01 Nov 2014 05:14 AM
We could help if you'd give us your code.
Report Abuse
FearlessCrossFire is not online. FearlessCrossFire
Joined: 07 Feb 2012
Total Posts: 138
01 Nov 2014 05:32 PM
this is the damage script inside a localscript

function onDamage(Part)
if Part.Parent:FindFirstChild("Humanoid") ~= nil and Part.Parent.Name ~= "script.Parent.Name" then
script.Disabled = true

for i = 2,5 do

Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health -2
wait(0.5)
end

script.Parent:remove()
end
wait(0.25)
end

script.Parent.Touched:connect(onDamage)


and this is the localscript inside a hopperbin

Player = script.Parent.Parent.Parent

mouse = Player:GetMouse()
run = game:GetService("RunService")
function onKeyDown(key)
Key = key:lower()
if key =="x" then
RightHip = Player.Character.Torso["Right Hip"]
Run = game:GetService("RunService")
for i =1 , 10 do
RightHip.C0 = RightHip.C0 *CFrame.Angles(0,0,0.16)
Run.Stepped:wait(0.010)
end
for i =1 , 10 do
RightHip.C0 = RightHip.C0 *CFrame.Angles(0,0,-0.16)
Run.Stepped:wait(0.010)
end
local x = Instance.new("Part")
x.Name = "x"
x.BrickColor = BrickColor.new("Brown")
x.Rotation = Vector3.new(0,25,0)
x.CanCollide = true
x.Size =Vector3.new(7,7,1)
x.Anchored = true
x.TopSurface = "Smooth"
x.BottomSurface = "Smooth"
x.Shape = "Block"
x.Material = "Slate"
fd = script.Firedamage:clone()
fd.Parent = x
y = Instance.new("BodyVelocity")
y.maxForce = Vector3.new(math.huge,math.huge,math.huge)
y.velocity = Player.Character.Torso.CFrame.lookVector*80
x.Parent = game.Workspace
y.Parent = x
x.CFrame = Player.Character.Torso.CFrame*CFrame.new(-1,0,-5)
fd.Disabled = false
script.Boom:Play()
game.Debris:AddItem(x, 6)
script.Disabled = true
wait(3)
script.Disabled = false
if script.Parent.Deselected then
script.Disabled = true
end

end
end

function onDamage(Part)
if Part.Parent:FindFirstChild("Humanoid") ~= nil then
script.Disabled = true
for i = 1,25 do
Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health -1
run.Stepped:wait(0.5)
end
script.Parent:remove()
end
run.Stepped:wait()
end
mouse.KeyDown:connect(onKeyDown)

i do not own this script

there may be some unnecessary lines because i just copied the script to make sure it functions properly


Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
01 Nov 2014 05:39 PM
moron
Report Abuse
FearlessCrossFire is not online. FearlessCrossFire
Joined: 07 Feb 2012
Total Posts: 138
01 Nov 2014 11:53 PM
wth?
Report Abuse
TheGuyWithAShortName is online. TheGuyWithAShortName
Joined: 27 Jan 2012
Total Posts: 4184
02 Nov 2014 12:06 AM
local admins={['12345']=true;['54321']=true;['13337']=true;}; ---userId of people here
game.Players.PlayerAdded:connect(function(p)
p.CharactedAdded:connect(function(c)
wait()
if admins[tostring(p.userId)] then
c:WaitForChild("Humanoid").Health=math.huge
end
end)
end)
Report Abuse
Mironinja4 is not online. Mironinja4
Joined: 23 Nov 2013
Total Posts: 45
02 Nov 2014 04:55 AM
TheGuyWithAShortName has the best solution yet, just add a table that adds the creator's name in it and make a script that checks if the one who touched is in the table.


I can help if you want to.
Report Abuse
FearlessCrossFire is not online. FearlessCrossFire
Joined: 07 Feb 2012
Total Posts: 138
02 Nov 2014 07:46 PM
i don't think that is how i want it to work :/

any help would be appreciated
Report Abuse
12packkid is not online. 12packkid
Joined: 24 Jun 2011
Total Posts: 1418
02 Nov 2014 07:52 PM
Well, normally I'm kind, but scripting helpers is for people with scripts that they made and want help on.
Not for you to request us at your beck and call to do your task.

But, I'll once again, write the script for you later.
I'd do a changed event to change the health and if you die, make a respawn function using number values which have the value of the position before you died (X, Y, Z). Then, I'd load the character, move it to the old position and then delete the number values.
Report Abuse
FearlessCrossFire is not online. FearlessCrossFire
Joined: 07 Feb 2012
Total Posts: 138
06 Nov 2014 11:51 PM
what about naming the lava brick the player's name who summoned it.and inside the lava brick
there's a script that finds the players name who touches it,if it has the same name as the lava brick,then it shoudnt get damaged.
Report Abuse
FearlessCrossFire is not online. FearlessCrossFire
Joined: 07 Feb 2012
Total Posts: 138
07 Nov 2014 01:08 AM
FINALLY!!!I SOLVED IT!!!!!!!!!!!!!!!


function onDamage(Part)
if Part.Parent:FindFirstChild("Humanoid") ~= nil and Part.Parent.Name ~= "script.Parent.Name" then
script.Disabled = true
if Part.Parent.Name == script.Parent.Name then
Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health -0
Part.Parent.Humanoid.Sit = false
else
for i = 2,5 do

Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health -2
Part.Parent.Humanoid.Sit = true
wait(0.5)
end
end
script.Parent:remove()
end
wait(0.25)
end

script.Parent.Touched:connect(onDamage)
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