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

trouble changing a Vector3Value inside a character?

Asked by 6 years ago
01local debounce = false
02script.Parent.Touched:Connect(function(hit)
03 
04    local value = hit.Parent:WaitForChild("HomePos")
05 
06    if hit.Parent:FindFirstChild("Humanoid") and value.Value == Vector3.new(0,0,0) then
07 
08    if not debounce then debounce = true
09        local newpos = script.Parent.Parent.TpPoint
10 
11        value.Value = Vector3.new(newpos.Position)
12    end
13    end
14end)

Im having trouble setting a vector3 values vector3 using a parts position. there are no errors and if I give it an x,y,z value it works fine but not if I use a parts position. I suspect im using this wrong, but dont be afraid to correct me.

1 answer

Log in to vote
1
Answered by 6 years ago

You do not need to construct a new Vector3 value in line 11. The Position property already returns a Vector3.

01local debounce = false
02script.Parent.Touched:Connect(function(hit)
03 
04    local value = hit.Parent:WaitForChild("HomePos")
05 
06    if hit.Parent:FindFirstChild("Humanoid") and value.Value == Vector3.new(0,0,0) then
07 
08    if not debounce then debounce = true
09        local newpos = script.Parent.Parent.TpPoint
10 
11        value.Value = newpos.Position
12    end
13    end
14end)
0
thanks, I knew it was something small hiding under my nose. mantorok4866 201 — 6y
Ad

Answer this question