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

Why is my text for my capture point not working when I put variables into the message?

Asked by
kofe_i 4
5 years ago

I took some random free model capture point off the toolbox, and attempted to modify it to become a capture point that updates a GUI at the top of the screen that keeps track of how long each team has held it. However, I keep getting some errors and the GUI won't update with the variables. I'm almost certain I'm doing something really stupid, but I've tried to fix this many many times, and it just refuses to work with variables. How do I fix this?

(The code that gets an error is the line below this sentence, and the script is in the screengui as a localscript)

script.Parent.TextLabel.Text = "Team holding: BLU BLU:" tostring(blu) " RED:" tostring(red)

(all code if needed)

team = game.Workspace["Capture point"].Part

pole = game.Workspace["Capture point"].Pole

local teamholding = "None"

local red = 0

local blu = 0

function onTouch(hit)

local user = game.Players:GetPlayerFromCharacter(hit.Parent)

if user ~= nil then

team.BrickColor = user.TeamColor

pole.Handles.Color = user.TeamColor

print(user.TeamColor)



if user.TeamColor.Name == "Navy blue" then

teamholding = "BLU"

script.Parent.TextLabel.Text = "Team holding: BLU BLU:" tostring(blu) " RED:" tostring(red)



end



while teamholding == "BLU" do

blu = blu + 1

script.Parent.TextLabel.Text = "Team holding: BLU BLU:" tostring(blu) " RED:" tostring(red)

wait(1)

end



if user.TeamColor.Name == "Really red" then

teamholding = "RED"

script.Parent.TextLabel.Text = "Team holding: BLU BLU:" + tostring(blu) +" RED:" + tostring(red)

while teamholding == "RED" do

red = red + 1

script.Parent.TextLabel.Text = "Team holding: BLU BLU:" + tostring(blu) +" RED:" + tostring(red)

wait(1)

end



end

end

end



team.Touched:connect(onTouch)

1 answer

Log in to vote
0
Answered by 5 years ago

The problem is simple: You have no concatenation symbols.

Concatenation is the act of inserting a string or number into another string. Lua's symbol for concatenation is two periods ... Here is an example of concatenation:

script.Parent.TextLabel.Text = "Team holding: BLU BLU: " .. tostring(blu) .. " RED: " .. tostring(red)

The above line should make the following string:

"Team holding: BLU BLU: (blu) RED: (red)"

Concatenation is simple and rather easy, and it will become very useful to you.

0
"(blu)" is the first tostring and "(red)" is the second DeceptiveCaster 3761 — 5y
Ad

Answer this question