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

Why isn't this cloning the model to workspace?

Asked by
F_lipe 135
7 years ago

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

0
I did just notice whenever I click it moves the Unions position still but only in ServerStorage F_lipe 135 — 7y

1 answer

Log in to vote
1
Answered by
RedCombee 585 Moderation Voter
7 years ago

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.

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. F_lipe 135 — 7y
0
I also just realize it doesn't work in an actual server but it does work on testing mode F_lipe 135 — 7y
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 F_lipe 135 — 7y
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. RedCombee 585 — 7y
Ad

Answer this question