Hello, I've recently made a GUI with classes in it, for when the player joins the game, they'll have to select one of said classes to use in game, and after selection, the frame is destroyed. Why won't this function without error codes?
local primary = game.ServerStorage.AK47 local secondary = game.ServerStorage.Baretta local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:Connect(function(click) if script.Parent.MouseButton1Click == true then player.FindFirstChild("Backpack") primary:Clone() secondary:Clone() script.Parent.Parent:Destroy() end end)
There are a couple of problems with your code here, those being that :
:
instead of .
With that said, here is a fixed version
Local Script
```lua local RP = game:GetService("ReplicatedStorage") local remote = RP.RemoteEvent
script.Parent.MouseButton1Click:Connect(function() RP:FireServer() script.Parent.Parent:Destroy() end) ``` Server Script
```lua local RP = game:GetService("ReplicatedStorage") local remote = RP.RemoteEvent local primary = RP.AK47 local secondary = RP.Baretta
RP.OnServerEvent:Connect(function(plr) local p = primary:Clone() local s = secondary:Clone() p.Parent = plr.Backpack end) ```
The scripts above do not really seem safe and rational to many people, and indeed, it isn't.
This is because, the client can too easily get multiples of the same tools simply by firing the remote multiple times.
To prevent this, you can simply use a boolean value to stop the client from simply firing the event multiple times to get multiple guns
A couple of other things you should take away here are that:
Hopefully that helped!