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 » Scripters
Home Search
 

Re: Help

Previous Thread :: Next Thread 
ColinRocks99 is not online. ColinRocks99
Joined: 04 May 2013
Total Posts: 1533
11 Feb 2017 11:49 AM
I'm trying to do this thing were if a player touches a brick, the player will die. But I'm trying to make it so if the players team color is the same color as the brick, the player doesn't die. I wrote something but it doesn't work. Can someone fix it up?

function onTouched(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
if (humanoid ~= nil) then
local plr = humanoid.Parent
local name = plr.Name
local playerinplayers = game.Players:FindFirstChild(name)
if playerinplayers.TeamColor ~= script.Parent.BrickColor then
humanoid.MaxHealth = 0 ---change number to what you want max health to be
end
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
11 Feb 2017 11:51 AM
local part = script.Parent

part.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and part.BrickColor ~= player.TeamColor then
player.Character:BreakJoints()
end
end)


Report Abuse
ColinRocks99 is not online. ColinRocks99
Joined: 04 May 2013
Total Posts: 1533
11 Feb 2017 01:07 PM
if I wanted to use that script with 'takedamage', is this correct:

Damage = script.Parent.Config.Damage.Value
local part = script.Parent

part.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and part.BrickColor ~= player.TeamColor then
player.Character.Humanoid:TakeDamage(Damage)
end
end)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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