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

Why isn't this cloning the model to workspace?

I'm making a tool that when the player clicks it'll clone the c4 model to workspace and place it where they click. I have a Script a Local Script and a ClickEvent in the tool Here are the scripts in the order I named them

local tool = script.Parent
local clickEvent = tool.ClickEvent
local player=game.Players.LocalPlayer
local c4 = game.ServerStorage.C4Model
local clickEventConnection



local function createC4(location)
	c4:Clone(game.Workspace)
	c4.CFrame = location
	
end



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

local function onEquip()
	clickEventConnection = clickEvent.OnServerEvent:connect(onClick)
end
 
local function onUnequip()
	clickEventConnection:disconnect()
end
 
tool.Equipped:connect(onEquip)
tool.Unequipped:connect(onUnequip)
--Variables
local tool=script.Parent
local player=game.Players.LocalPlayer
local mouse=player:GetMouse()
local clickEvent = tool.ClickEvent

--Scripts

local function onActivate()
	local clickLocation=mouse.Hit
	clickEvent:FireServer(clickLocation)
	
end
tool.Activated:connect(onActivate)
print("Got Click")


I'm not getting any errors in output

1 comment

0

I did just notice whenever I click it moves the Unions position still but only in ServerStorage

1 answer

✓ Accepted answer

On line 10, try:

c4:Clone().Parent = game.Workspace

If that doesn't fix your problem, feel free to come back and maybe we can figure it out.

4 comments

0

This helped and it is now successfully cloning into workspace but the clicks are 1 behind hard to explain, but when I originally click it places one where it was at the start and then when I click somewhere else it places it where I previously clicked.

0

I also just realize it doesn't work in an actual server but it does work on testing mode

0

On dev console im getting a error that ClickEvent is not in tool so I think some how it's removing itself from the tool it actual servers

0

I don't know if I can help you with that since you have given limited information about the game, but since your initial problem is solved, you should probably accept this as the answer and create a new question with more information.

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