I made this script that can help give a random value for ur local script firing and fire the random value and is this a efficent security method? (minds this is all a example this isnt actully true)
Random value script ;
function(Generate) local N1 = math.random(1,9) local N2 = math.random(1,9) local N3 = math.random(1,9) local N4 = math.random(1,9) local N5 = math.random(1,9) local N6 = math.random(1,9) local Code = N1 * N5 ^ N2 /N3 + N4 - N6 local Codedisplay = Instance.new("Part",game.Workspace) Codedisplay.Name = Code end game.ReplicatedStorage.BindableEventExample.Event:connect(Generate)
Local script:
script.Parent.Touched:connect(function(part) local plr = game.Players:GetPlayerFromCharacter(part.Parent) game.ReplicatedStorage.ServerEvent:FireServer(plr,game.Workspace.Codedisplay.Name) end)
ServerScript:
while true do wait(0.5) game.ReplicatedStorage.BindableEventExample:Fire() end game.ReplicatedStorage.ServerEvent.OnServerEvent:connect(function(plr,Code) if Code = game.Workspace.Codedisplay.Name then plr.Character.Humanoid.Health = 0 end end)
You know, the OnServerEvent of RemoteEvent first parameter will always be the player who fired it, so the variable plr is representing who fired the event, and variable code is being represented by local plr = game.Players:GetPlayerFromCharacter(part.Parent). So the actual CodeDisplay.Name you sent to the serverevent would be a third parameter.
But you can just sanity check who fired the event on the server with that first parameter to prevent hacking. Even though the hacker would still be able to just delete the touched event, in which case he wouldn't be affected by it, so its just better to let the touched event fire serverside too.