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

Click detector won't output once taken from replicated storage?

-I apologize if this post isn't structured correctly, I'm new-

I've made a crate, that when clicked places a tool version in the player's inventory, once they press Q it takes a physical version out of replicated storage at the tool's position

The crate that's in the workspace is identical to the one in replicated, and when you click on the crate in the workspace everything works fine, and when you press Q it "drops" the crate just fine however once cloned the click detector stops working I've made sure both crates are completely identical. I don't know if it matters but the crates are both unions

This is the part of the script in charge of cloning the crate out of replicated storage

(This is a local script)

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local crate = game.ReplicatedStorage.Crate
local handle = script.Parent.Handle
	 
game:GetService("UserInputService").InputBegan:connect(function (input, _)
    if input.KeyCode == Enum.KeyCode.Q then
	print("Dropped!")
	local newPart = crate:Clone()
	newPart.Parent = game.Workspace
	newPart.Position = handle.Position
	newPart.Orientation = handle.Orientation
	newPart.Pickup.Disabled = false
	script.Parent:Destroy()
    end
end)

This is for picking up the crate, the script works just fine for the crate that's already in the workspace, but once cloned out of replicated the script no longer works

(This is a normal script)

local crate = script.Parent
local invCrate = game.ReplicatedStorage["Light Crate"]

script.Parent.ClickDetector.MouseClick:connect(function(player)
	print("Picked Up!")
	local newPart = invCrate:Clone()
	newPart.Parent = player.Backpack
	crate:Destroy()
end)

I'm completely lost and any help would be much appreciated!

4 comments

0

Can you show all of the local & server script?

0

Also, it's not a very good idea to be cloning things from a local script

0

Ok, I edited it, why not clone with local scripts? I don't fully understand all the differences between them

0

Actually, if cloning isn't the best idea, would it be wiser to have the crate stored inside the tool instead? Since picking up the craft clones the tool from replicated, I wouldn't have to worry about needing to clone anything, the local script would merely move the crate to the right spot Edit: Darn, I tried it, but still run into the same problem

1 answer

The problem is I'm trying to clone from a local script, so the cloned object cannot be recognized by the server, I have to figure out how to clone the part from a normal script in order for the click detector to still be functional

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