Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why's the script not moving the model I made?

I'm making a tool for a friend and I'm not understanding why the car isn't moving. (the car is a Model)

local tool = script.Parent
local clickEvent = tool.ClickEvent
local spawnblock = game.Workspace.spawnblock
local clickEventConnection

local function createPart(location)
	local car = game.ReplicatedStorage.Assets.Car
	car:clone()
	car.Parent = game.Workspace
	car:SetPrimaryPartCFrame(Vector3(spawnblock.CFrame))
end

local function onClick(player, clickLocation)	
	createPart(clickLocation)
end

local function onEquip()
	clickEventConnection = clickEvent.OnServerEvent:connect(onClick)
end


tool.Equipped:connect(onEquip)

1 answer

local tool = script.Parent
local clickEvent = tool.ClickEvent
local spawnblock = game.Workspace.spawnblock
local clickEventConnection

local function createPart(location)
    local car = game.ReplicatedStorage.Assets.Car
    car:clone()
    car.Parent = game.Workspace
    car:SetPrimaryPartCFrame(Vector3.new(spawnblock.CFrame)) -- needed .new after Vector3
end

local function onClick(player, clickLocation)   
    createPart(clickLocation)
end

local function onEquip()
    clickEventConnection = clickEvent.OnServerEvent:connect(onClick)
end


tool.Equipped:connect(onEquip)

2 comments

0

It says "Unable to cast Vector3 to CoordinateFrame"

0

im not getting that error. i must didnt do what you did

This discussion is preserved as it was. New answers, comments, and votes are closed.