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

Model won't get cloned to Cursor.hit.p?

Asked by 4 years ago

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!

0
Change line 8 to Raft:MoveTo(Cursor.Hit.p) Leamir 3138 — 4y
0
Hello, thanks for ther answer, however, that did not fix my problem. It cloned the Raft to the position I gave before putting in in Replicated Storage. RazzyPlayz 497 — 4y
0
Is the raft welded? If so, did you specify a primary part? User#30567 0 — 4y
0
Yes, the Raft has all parts Welded with a Weld Constraint to the Base which is the Main part or Primary Part RazzyPlayz 497 — 4y
0
I have also noticed that upon the Raft spawning to the original coodrinations, the Vehicle Seat which you drive the raft with is non functional with the new clone RazzyPlayz 497 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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.

0
That worked! Thank you so much! Also no need, It's a single player game so I won't have other players to see it! Thansk for the answer :D RazzyPlayz 497 — 4y
0
ok asdfghjk9019 225 — 4y
Ad

Answer this question