Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why the valor isnt part of workspace when it is created?

Asked by 7 years ago

I done a script when a player touch a block if he is in a determined team, the team will add a +1 to TeamA or B but when I touch the block it doesnt work. What can be the trouble?

01local TeamA = Instance.new("NumberValue")
02TeamA.Name = ("TeamA")
03TeamA.Value = 0
04TeamA.Parent = workspace
05 
06local TeamB = Instance.new("NumberValue")
07TeamB.Name = ("TeamB")
08TeamB.Value = 0
09TeamB.Parent = workspace
10 
11script.Parent.Touched:connect(function(hit) --Get what made the hit.
12    --Define player's variable here with the method GetPlayerFromCharacter!
13    local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
14    script.Parent.BrickColor = Player.TeamColor
15    wait(.2)
View all 30 lines...
0
Is the team in the player? therealae 7 — 7y

1 answer

Log in to vote
0
Answered by
OfcPedroo 396 Moderation Voter
7 years ago
Edited 7 years ago

I know what's going on.

A thing I learned recently: When there's a .Touched event, the LocalScript / Script NEEDS to be putted in the StarterGui. Other thing, I don't really like using NumberValues, I would recommend you using IntValues. Having said that, here's what you want:

01local TeamA = Instance.new("IntValue") --Change to IntValue.
02TeamA.Name = "TeamA" --Remove the ()
03TeamA.Value = 0
04TeamA.Parent = game.Workspace --Make sure he knows what's workspace.
05 
06local TeamB = Instance.new("IntValue") --Change to IntValue.
07TeamB.Name = "TeamB" --Remove the ()
08TeamB.Value = 0
09TeamB.Parent = game.Workspace --Make sure he knows what's workspace.
10 
11script.Parent.Touched:connect(function(hit) --Get what made the hit.
12    --Define player's variable here with the method GetPlayerFromCharacter!
13    --local Player = game.Players:GetPlayerFromCharacter(hit.Parent): This works, but there's another way I prefer.
14 
15    local Character = hit.Parent.Name
View all 31 lines...

After 2 hours, here's your script there up ^^

If this solves your problem, please mark as the solution.

As always, good scripting!

0
thanks you HillsMaster 34 — 7y
0
np! ;D OfcPedroo 396 — 7y
0
but it didnt worked HillsMaster 34 — 7y
0
strange OfcPedroo 396 — 7y
0
course, you have to change the script.Parent on line 11. Remember, I said you have to put it in the StarterGui, so that and every script.Parent would change. OfcPedroo 396 — 7y
Ad

Answer this question