I want to protect my game from exploiters that fire events to create parts. I don't want replies saying "this won't help at all!1", because I have a system that'd work with this.
Here's my local script context:
script.Parent.Activated:Connect(function() game:GetService("ReplicatedStorage").PartCreate:FireServer("d85jh34hdfj3dg") end)
Here's my server side script context:
game:GetService("ReplicatedStorage").PartCreate.OnServerEvent:Connect(function(Player) local Part = Instance.new("Part") Part.Parent = game:GetService("Workspace").Parts Part.Name = "ClientPart"; Part.Position = Player.Character.Torso.Position Part.Size = Vector3.new(4, 1, 2) Part.BrickColor = BrickColor.Random() Part.CanCollide = true Part.Anchored = false end)
Now how can I have the script only fire if the password is correct?
You need to add the password argument to the function you are creating on the server, so that you can check to see if it is valid.
game:GetService("ReplicatedStorage").PartCreate.OnServerEvent:Connect(function(Player, password) -- Check if password is correct if password == "d85jh34hdfj3dg" then local Part = Instance.new("Part") Part.Parent = game:GetService("Workspace").Parts Part.Name = "ClientPart"; Part.Position = Player.Character.Torso.Position Part.Size = Vector3.new(4, 1, 2) Part.BrickColor = BrickColor.Random() Part.CanCollide = true Part.Anchored = false end end)