Hello!
I ran into a problem that I can’t quite put my finger on, I am unable to define this variable and/or print it. I can’t find an answer, any help is appreciated
-- located in started pack
-- is a local script
-- script.parent.parent is the player
while true do wait(1)
local distance = math.sqrt(math.pow(math.max(script.Parent.Parent.RespawnLocation.Position.X,
script.Parent.Parent.RespawnLocation.Position.Y) - math.min(script.Parent.Parent.RespawnLocation.Position.X,
script.Parent.Parent.RespawnLocation.Position.Y),2) + math.pow(math.max(mouse.Hit.p.X,mouse.Hit.p.Y) -
math.min(mouse.Hit.p.X,mouse.Hit.p.Y),2))
print(distance)
end
I think it would be better if you just do all the calculations in seperate lines. It’s jumbled up into one single variable and it’s hard to read them all.
All spread out, easy to read, however it still does not print.
while true do wait(1)
local a = math.max(script.Parent.Parent.RespawnLocation.Position.X,
script.Parent.Parent.RespawnLocation.Position.Y)
local b = math.min(script.Parent.Parent.RespawnLocation.Position.X,
script.Parent.Parent.RespawnLocation.Position.Y)
local c = math.max(mouse.Hit.p.X,mouse.Hit.p.Y)
local d = math.min(mouse.Hit.p.X,mouse.Hit.p.Y)
local distance = math.sqrt(math.pow(a - b) + math.pow(c-d))
print(distance)
end
task.spawn(function()
while task.wait(1) do
local a = math.max(script.Parent.Parent.RespawnLocation.Position.X,
script.Parent.Parent.RespawnLocation.Position.Y)
local b = math.min(script.Parent.Parent.RespawnLocation.Position.X,
script.Parent.Parent.RespawnLocation.Position.Y)
local c = math.max(mouse.Hit.p.X,mouse.Hit.p.Y)
local d = math.min(mouse.Hit.p.X,mouse.Hit.p.Y)
local distance = math.sqrt(math.pow(a - b) + math.pow(c-d))
print(distance)
end
end)