Click detector won't output once taken from replicated storage?
Asked by
5 years ago Edited 5 years ago
-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)
01 | local player = game.Players.LocalPlayer |
02 | local mouse = player:GetMouse() |
03 | local crate = game.ReplicatedStorage.Crate |
04 | local handle = script.Parent.Handle |
06 | game:GetService( "UserInputService" ).InputBegan:connect( function (input, _) |
07 | if input.KeyCode = = Enum.KeyCode.Q then |
09 | local newPart = crate:Clone() |
10 | newPart.Parent = game.Workspace |
11 | newPart.Position = handle.Position |
12 | newPart.Orientation = handle.Orientation |
13 | newPart.Pickup.Disabled = false |
14 | script.Parent:Destroy() |
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)
1 | local crate = script.Parent |
2 | local invCrate = game.ReplicatedStorage [ "Light Crate" ] |
4 | script.Parent.ClickDetector.MouseClick:connect( function (player) |
6 | local newPart = invCrate:Clone() |
7 | newPart.Parent = player.Backpack |
I'm completely lost and any help would be much appreciated!