This is the script:
function onTouch(hit)
mouse.Button1Down:Connect(function()
if hit.Name == "Sand" then
hit.Size = hit.Size -0.1
end
end)
end
script.Parent.Touched:Connect(onTouch)
This is the script:
function onTouch(hit)
mouse.Button1Down:Connect(function()
if hit.Name == "Sand" then
hit.Size = hit.Size -0.1
end
end)
end
script.Parent.Touched:Connect(onTouch)
You cannot decrease a part's size property that way. You need to reduce its size by using a new Vector3. Also I'm not sure why you are defining Button1Down inside a Touched event, but I'm leaving it there anyways.
function onTouch(hit)
mouse.Button1Down:Connect(function()
if hit.Name == "Sand" then
hit.Size = Vector3.new(hit.Size.X - 0.1, hit.Size.Y - 0.1, hit.Size.Z - 0.1)
end
end)
end)
script.Parent.Touched:Connect(onTouch)
Ok here is what you are doing wrong. First of all, I think you should make this script a bit.... easier to read. Unless you are going to use that function again you should probably format it differently.
script.Parent.Touched:Connect(function(hit)
end)
Instead of:
function OnTouch()
end
script.Parent.Touched:Connect(OnTouch)
Ok so now that that is over with, you need to change line 4 to this line:
hit.size = hit.size - Vector3.new(0.1, 0.1, 0.1)
If there is still a problem after you do this, it is most likely NOT the size.
dang it too lat
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
I'd venture to guess it's because you are trying to subtract 0.1 from a Vector3. Try hit.Size = hit.Size - Vector3.new(-0.1, -0.1, -0.1)
Also you might want to consider changing your code. I don't believe it will work how you expect it to.