How to fix attempt to concatenate string with userdata ?
Asked by
5 years ago Edited 5 years ago
Hello! I was researching about player input and i tried a script
01 | local Players = game:GetService( "Players" ) |
02 | local player = Players.LocalPlayer |
03 | local mouse = player:GetMouse() |
05 | local function onMouseClick() |
06 | print (player.Name .. " clicked at position: " .. mouse.Hit.p) |
08 | print ( "Clicked part: " .. mouse.Target:GetFullName()) |
10 | print ( "No part clicked" ) |
13 | mouse.Button 1 Down:Connect(onMouseClick) |
This script is a local script and it was put in StarterPlayerScripts
When i was testing, the output said
Players.Nguyenlegiahung.PlayerScripts.LocalScript:6: attempt to concatenate string with userdata
I changed line 6 to
print(mouse.Hit.p)
and it was working, but how do I concatenate this?
Hope you can help :D
Thanks for reading my bad English
Edit: I was able to fix it by doing
1 | mouse.Hit.p.X..mouse.Hit.p.Y..mouse.Hit.p.Z |
Is there a more efficient way to do this?