Hello,
I am currently making a survival game and I am trying to make a tool which can spawn a model upon using the tool. When I use the tool it clones the Model to workspace but it doesn't give the position of Cursor.hit.p.
I am aware that models do not have a position so how would I go to make it so the model goes to the mouse position?
I have a LocalScript
Inside my Tool:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local Player = game:GetService("Players").LocalPlayer local Raft = ReplicatedStorage:WaitForChild("Raft") local Cursor = Player:GetMouse() function onActivated() Raft:Clone().Parent = workspace Raft:MoveTo(Cursor.hit.p) end script.Parent.Activated:connect(onActivated)
If I could get some help with this script, that would be great!
Thanks!
i think i know whats the problem,when you are saying to the raft to move Raft:MoveTo(Cursor.hit.p)
it referring to the raft in replicated storage and not to the raft you just cloned,
a simple way to fix is to add a variable to what you are cloning, ex.
local ReplicatedStorage = game:GetService("ReplicatedStorage") local Player = game:GetService("Players").LocalPlayer local Raft = ReplicatedStorage:WaitForChild("Raft") local Cursor = Player:GetMouse() function onActivated() local ClonedRaft = Raft:Clone() ClonedRaft.Parent = game.workspace ClonedRaft:MoveTo(Cursor.hit.p) end script.Parent.Activated:connect(onActivated)
also you might notice that the raft is only visible to the Client but other players cant see it. this is because you are using a local script. if you want me to explain to you how you can make it visible to the server, i will.