|
| 22 Sep 2017 12:44 AM |
playerName = nil script.Parent.Touched:connect(function(hit) if playerName == nil then playerName = hit.Parent.Name print(playerName) script.Parent.BrickColor = BrickColor.new("Navy blue") end end)
script.Parent.TouchEnded:connect(function(hit) print(playerName) script.Parent.BrickColor = BrickColor.new("Really red") end end)
This is a script I made to help out my friend. He is making a duel sword fighting game and basically this script changes the brickColor to Navy Blue when touched and when you get away from the brick, it turns back to Really red. The playerName is a variable that I used to register the names of the player that touch it so I can send them to the duel arena. Please fix it someone. The entire touchEnded function isn't working |
|
|
| Report Abuse |
|
|
Em_ily
|
  |
| Joined: 21 Jan 2014 |
| Total Posts: 1708 |
|
|
| 22 Sep 2017 03:24 AM |
| Use a StringValue, playerName.Value . . . |
|
|
| Report Abuse |
|
|
Em_ily
|
  |
| Joined: 21 Jan 2014 |
| Total Posts: 1708 |
|
|
| 22 Sep 2017 03:28 AM |
script.Parent.Touched:connect(function(hit) if hit then local playerName = hit:FindFirstChild('Parent').Name print(playerName) script.Parent.BrickColor = BrickColor.new('Navy blue') end end)
script.Parent.TouchEnded:connect(function(hit) local playerName = hit:FindFirstChild('Parent').Name print(playerName) script.Parent.BrickColor = BrickColor.new('Really red') end end)
-- Should work? |
|
|
| Report Abuse |
|
|
Em_ily
|
  |
| Joined: 21 Jan 2014 |
| Total Posts: 1708 |
|
|
| 22 Sep 2017 03:32 AM |
Also you don't need their name, you could just do:
for i,v in pairs(game.Players:GetPlayers()) v.Character.Humanoid:MoveTo(game.workspace.Part.Position) end
Inside of the brick... |
|
|
| Report Abuse |
|
|
|
| 22 Sep 2017 05:54 AM |
:Connect not :connect
#code error("you're*") |
|
|
| Report Abuse |
|
|
| |
|