Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help Me: Firing Events With A Value?

Asked by 5 years ago
Edited 5 years ago

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?

0
Please make it recognized as code before I help you. To'do this add ~~~~~~~~~~~~~~~~~ at the top and bottom of your code. casper123123123 357 — 5y
0
Done. Chaddaking 60 — 5y
0
Is the password the variable you are sending? casper123123123 357 — 5y
0
d85jh34hdfj3dg Chaddaking 60 — 5y
0
Yeah that won't help you. Exploiters can see what variables you are passing through a RemoteEvent making your efforts pointless. casper123123123 357 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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)
Ad

Answer this question