Basically I have a customization system. When the player selects a hat, I need the hat to be cloned and put into the players character.
I'm not to familiar with using events, etc. How can I go about using an event or at least make this work in FilteringEnabled? I simply need to clone an item into the player's character in Workspace from ReplicatedStorage.
Hey ViciousViperV2,
FilteringEnabled
on. First, I would put a RemoteEvent
in Replicated Storage
and then put the LocalScript
under the Button that the player will need to click in order for the hat to be selected. Then, when the player selects a hat, I would activate that RemoteEvent
's OnServerEvent, which the ServerScript
should be listening for and then the ServerScript
is what would clone the hat into the Character
. That's the basis of what I would do. I will show you a personal example of the 2 events in-use and link you to a wiki page that can help you perhaps understand them better. Here is the wiki page for RemoteEvent
s being used and below is the code that will show a RemoteEvent
in-use.LocalScript
to fire the RemoteEvent
:local button = script.Parent -- Declares a variable for the button that will be pressed to select the hat. local rs = game:GetService("ReplicatedStorage") -- Declares a variable for Replicated Storage. button.MouseButton1Down:Connect(function() -- Anonymous function using the MouseButton1Down event of a Button, which detects a left click down. Wasn't sure how you wanted the selection to work but, you can substitute this event for another. local event = rs:WaitForChild("RemoteEvent") -- Declares a variable for the Remote Event. event:FireServer() -- Activates the OnServerEvent for the Remote Event's listeners end) -- end for the anonymous function. The parenthesis is important because that's how anonymous functions end.
local rs = game:GetService("ReplicatedStorage") -- Declares a variable for the ReplicatedStorage local hat = rs:WaitForChild("Hat") -- Declares a variable for the Hat that is being cloned. local event = rs:WaitForChild("RemoteEvent") -- Declares a variable for the RemoteEvent event.OnServerEvent:Connect(function(plr) -- Anonymous function listening to the OnServerEvent from the RemoteEvent. local char = workspace[plr.Name] -- A variable for the Character. local new_hat = hat:Clone() -- A variable for the hat's clone. new_hat.Parent = char -- Parenting the hat to the Character. end) -- end for the anonymous function.
Client
and the Server
.~~ KingLoneCat