Hello! I scripted this thing for touch tapinworld. The idea is to get the lookvector of the players tap. But it returns unable to cast vector2 to float. I have no idea what the problem is. Can someone help me please?
uis.TouchTapInWorld:Connect(function(pos, proccesed)
if not proccesed and equiped == true then
if db == false then
db = true
local camera = workspace.CurrentCamera
-- Get the position where the touch occurred
local touchPosition = pos
print(pos)
-- Use ViewportPointToRay to cast a ray from the touch position into the world
local ray = camera:ViewportPointToRay(touchPosition)
-- Now you can use the ray for various purposes, such as detecting hits with parts in the world
local hitPart, hitPosition = workspace:FindPartOnRay(ray, nil, false, true)
local vector = mouse.Hit.LookVector
local speed = script.Parent.Speed.Value
local Reload = script.Parent.ReloadTime.Value
if hitPosition then
local lookVectorAtHit = (hitPosition - camera.CFrame.Position).Unit
vector = lookVectorAtHit
end
anim:Play()
script.Parent.throwsfx:Play()
wait(0.3)
script.Parent.Handle.Transparency = 1
script.Parent.Throw:FireServer(vector)
wait(Reload-0.3)
script.Parent.Handle.Transparency = 0
db = false
end
end
end)