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

Positioning model to mouse position not working?

Asked by 3 years ago

I made an explosive tool in Roblox and I'm trying to make it clone a Model that gets sent to the mouse position, but whenever I activate the tool, this happens: 15:16:17.028 - Unable to cast Instance to CoordinateFrame This is my code:

Client:

local Player = game.Players.LocalPlayer
repeat wait() until Player.Character
local mouse = Player:GetMouse()
local Character = Player.Character
wait(0.3)
local Humanoid = Character:FindFirstChild("Humanoid", true)

local Animation = Humanoid:LoadAnimation(script.Animation)
script.Parent.Equipped:Connect(function()
    Animation:Play()
    Animation:AdjustSpeed(0.25)
    wait(0.30)
    Animation:AdjustSpeed(0)
end)
script.Parent.Unequipped:Connect(function()
Animation:Stop()
end)
script.Parent.Activated:Connect(function()
    Animation:Stop()
end)
script.Parent.Activated:Connect(function()
    local position = mouse.Hit.p
    script.Parent.BombDropped:FireServer(position)
end)

Server:

local bomb = script.Parent.Bomb
bomb.Parent = game.ServerStorage
script.Parent.BombDropped.OnServerEvent:Connect(function(position)
    print(position)
    local created = bomb:Clone()
    created.Parent = workspace
    created:SetPrimaryPartCFrame(position)
end)

Answer this question