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: Need 2 seconds of your time.

Previous Thread :: Next Thread 
7Mehdi is not online. 7Mehdi
Joined: 12 Jan 2015
Total Posts: 503
12 May 2015 03:47 PM
Hi, I have this script that is suppose to teleport you to Part2 if you touch Part1 and you have to be on team color Bright blue for this to work but it doesn't work, can someone please help me fix this?

local teamColor = BrickColor.new("Bright blue")
local startPart = script.Parent
local endPart = workspace.Part2

local function getCharacterFromHit(hit)
while hit.ClassName ~= "workspace" or hit.ClassName ~= "Model" do
hit = hit.Parent
end
if hit.ClassName == "Model" then
return hit
end
end

local function onTouch(hit)
local character = getCharacterFromHit(hit)
local player = character and game.Players:GetPlayerFromCharacter(character)

if player and player.TeamColor == teamColor and player.Neutral == false then
character:MoveTo(endPart.Position)
end
end

startPart.Touched:connect(onTouch)
Report Abuse
7Mehdi is not online. 7Mehdi
Joined: 12 Jan 2015
Total Posts: 503
12 May 2015 03:50 PM
😢
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
12 May 2015 03:52 PM
local teamColor = BrickColor.new("Bright blue")
local startPart = script.Parent
local endPart = workspace.Part2


startPart.Touched:connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr and plr.TeamColor == teamColor and not player.Neutral and plr.Character then
plr.Character:MoveTo(endPart.Position)
end
end)
Report Abuse
7Mehdi is not online. 7Mehdi
Joined: 12 Jan 2015
Total Posts: 503
12 May 2015 03:56 PM
thanks but it still doesn't work for some reason 😭
i think its because of the "and not player.Neutral and plr.Character"
any tips?
Report Abuse
7Mehdi is not online. 7Mehdi
Joined: 12 Jan 2015
Total Posts: 503
12 May 2015 03:57 PM
NVM FIXED*

THANK YOU WAR!
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
12 May 2015 03:58 PM
No problem, I'm glad I could help, but I could barely read your code so I kinda rewrote it lol.
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