|
| 14 Apr 2016 09:10 PM |
So I'm having this problem and I just can't figure out what I'm doing wrong. Basically, I have a brick that will change them name of a tool. For example, if the tool is called "x" and you touch the brick with the tool, the tool will be changed to "x, y"
Here's the script:
function tch(h) if h.Parent.ClassName == "Tool" then if h.Parent.Name == "Sauce" then h.Parent.Name = "P" h.Parent.Pepperoni.Transparency = 0 else if h.Parent.Name ~= "Dough" or "Sauce" then local name = h.Parent.Name h.Parent.Name = (name ", P") h.Parent.Pepperoni.Transparency = 0 end end end end
script.Parent.Touched:connect(tch) |
|
|
| Report Abuse |
|
|
|
| 14 Apr 2016 09:51 PM |
h.Parent.Name = (name ", P") is incorrect, it should be:
h.Parent.Name = (name, "P")
Also, the if h.Parent.Name ~= "Dough" or "Sauce" then should be:
if h.Parent.Name ~= "Dough" or h.Parent.Name ~= "Sauce" then
#code while true do end |
|
|
| Report Abuse |
|
|
|
| 14 Apr 2016 10:06 PM |
clime you can not concat 2 strings with a comma
h.Parent.Name = name .. "P"
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 15 Apr 2016 01:44 AM |
script.Parent.Touched:connect(function(hit) if hit.Parent:IsA("Tool") then if hit.Parent.Name == "Sauce" then hit.Parent.Name = "P" hit.Parent.Pepperoni.Transparency = 0 else if hit.Parent.Name ~= "Dough" or hit.Parent.Name ~= "Sauce" then hit.Parent.Name = hit.Parent.Name..", P" hit.Parent.Pepperoni.Transparency = 0 end end end end)
|
|
|
| Report Abuse |
|
|