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

Placement System Not Placing?

Asked by 3 years ago

Hello,

I am Currently making a placement system but for some reason, I can't get the position of the mouse over to the server-side using remote events

Client:

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local placeable = true

local Trampoline = game.ReplicatedStorage.Placeables.Trampoline.Placing.lvl1_Trampo_Placing:Clone()
local trampo = game.ReplicatedStorage.Placeables.Trampoline.Placing.lvl1_Trampo_Placing
Trampoline.Parent = workspace

local function Move()
    mouse.TargetFilter = Trampoline
    local posX = mouse.Hit.X
    local posY = mouse.Hit.Y
    local posZ = mouse.Hit.Z
    Trampoline:SetPrimaryPartCFrame(CFrame.new(posX, posY + 1, posZ))
end

mouse.Move:Connect(Move)

mouse.Button1Down:Connect(function()
    local position = mouse.Hit
    game.ReplicatedStorage.Events.Place:FireServer(position)
end)

Server:

game.ReplicatedStorage.Events.Place.OnServerEvent:Connect(function(position)
    print("Placed")
    local place = game.ReplicatedStorage.Placeables.Trampoline.lvl1_Trampo:Clone()
    place.Parent = workspace
    place:SetPrimaryPartCframe(CFrame.new(position))
end)

There Is An Error In The Console Too: "bad argument #1 (Vector3 expected, got Object)" (The error is from the server-side script.)

2 answers

Log in to vote
0
Answered by 3 years ago
local position = mouse.Hit.p
Ad
Log in to vote
0
Answered by 3 years ago

Still the same error: bad argument #1 (Vector3 expected, got Object)

Answer this question