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

Why wont my click then clone script work for my rick roll game?

local clickDetector = game.Parent

function onMouseClick()
	-- Get a reference to an existing object
	local original = workspace["Rick Astley"]
	-- Create the model copy
	local copy = original:Clone()
	-- Parent the copy to the same parent as the original
	copy.Parent = original.Parent
	-- Move the copy so it's not overlapping the original
	copy:SetPrimaryPartCFrame(CFrame.new(54.4, 0.5, -161.2))
end

3 comments

0

the 'game' keyword is for the game,game don't has parent(s).

0

oh im so stupid

0

but still didn't work

1 answer

The part of the script you forgot is the clickDetector.MouseClick:Connect(onMouseClick), The event of the clickdetector.

local clickDetector = game.Parent

function onMouseClick()
    -- Get a reference to an existing object
    local original = workspace["Rick Astley"]
    -- Create the model copy
    local copy = original:Clone()
    -- Parent the copy to the same parent as the original
    copy.Parent = original.Parent
    -- Move the copy so it's not overlapping the original
    copy:SetPrimaryPartCFrame(CFrame.new(54.4, 0.5, -161.2))
end

clickDetector.MouseClick:Connect(onMouseClick)

1 comment

0

didn't work. It said Workspace.Pepperonic Pizza.GiveItemScript:14: attempt to index nil with 'MouseClick'

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