Code in a script that's inside of a tool; I have a RemoteEvent thats in the script and when the player equips the tool it copies the RE and puts it into game.ReplicatedStorage with a different name. Now I need help somehow firing the Remote Event.
script.Parent.Equipped:Connect(function() local player = script.Parent.Parent.Name local RE = script.WeaponEquipped:Clone() RE.Name = ("Equipped" .. player) RE.Parent = game.ReplicatedStorage wait(1) game.ReplicatedStorage:FindFirstChild("Equipped" .. player):FireClient(player) end)
Output comes back with "Unable to cast value to object, line 7"
I mean, a few things.
First of all, you already store your new RemoteEvent as your "RE" variable, so there's no need to access it with FindFirstChild
Two, I don't see a point to you cloning the remote, but whatever floats your code.
And finally three, you're passing the player's name as the first argument to FireClient, which must be the player object!
Here's a way to do it, though by no means the best one. It depends.
--NOTE: Just an example, YMMV if you try to use this without modifications. local player = script.Parent.Parent local RE = script.WeaponEquipped:Clone() RE.Name = ("Equipped" .. player.Name) RE.Parent = game.ReplicatedStorage script.Parent.Equipped:Connect(function() wait(1) --Unnecessary wait? RE:FireClient(player) end)