HELP with disconnecting these events

SERVER

utilitiyEvents.closeGUI.OnServerEvent:Connect(function(plr,Gui)
	if typeof(Gui) ~= "string" then return end
	if plr.PlayerGui:FindFirstChild(Gui) then
		plr.PlayerGui[Gui]:Destroy()
	end
end)

utilitiyEvents.toggleSprint.OnServerEvent:Connect(function(player,toggle)
	if typeof(toggle) ~= "boolean" then return end
	player.Character.Humanoid.WalkSpeed = if toggle then 35 else 16
end)

CLIENT/LOCAL SCRIPT

local UIS = game:GetService('UserInputService')
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or script.Parent

local replicated = game:GetService("ReplicatedStorage")
local remotes = replicated:WaitForChild("Remotes")
local utilRemotes = remotes:WaitForChild("Utility")



UIS.InputBegan:connect(function(input,processed)
	if processed then return end
	if input.KeyCode == Enum.KeyCode.LeftShift then
		utilRemotes:WaitForChild("toggleSprint"):FireServer(true)
 	end
end)



UIS.InputEnded:connect(function(input)
 	if input.KeyCode == Enum.KeyCode.LeftShift then
		utilRemotes:WaitForChild("toggleSprint"):FireServer(false)
 	end
end)

note!

i do want to reuse those events too

Something like this?

local connectionA
local connectionB

connectionA = runService.RenderStepped:Connect(function()
--Code
end)

connectionB = remote.OnServerEvent:Connect(function(player)
--Code
end)

connectionA:Disconnect()
connectionB:Disconnect()
1 Like

yeah but when i try to fire those events again they dont run

A little off topic from your actual problem, but I’d recommend changing the walk speed on the client. Otherwise sprinting will feel weird and laggy to players

Why do these events need to be disconnected?

And open it up to being hacked. Server is just the logic if done right any lag would be on your connection.

@ Creator That is some very fine programming. It covers all the bases. You must be setting up the remote incorrectly. Almost nothing you can do would make that any better. A few small tweaks could be added, but the logic looks to be sound.

Yes, because it’s impossible for a hacker to run

game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 35

An open book to an exploiter. Anything sensitive belongs on the server. I’m not going to argue; this is a known practice with all client-server applications on any platform.

The player’s walk speed … isn’t sensitive …

2 Likes

Please name one game that does sprinting on server that doesn’t feel completely awful to control.

1 Like

The ones that don’t get hacked. I’ve never had a problem with this.
Of course, this is sensitive. It would give speedrunning a whole new meaning.

Literally the only difference between doing it on server and client is that client is instant and server has an annoying delay. Both are equally exploitable.

2 Likes

Now you have me arguing. I mean no offence to you; this is just how it is. An exploiter cannot touch server scripts, and the server is the law to the client. All you need from the client is the trigger sent via remote. “any lag would be on your connection.”

Yes, an exploiter cannot touch server scripts. But an exploiter can change their walk speed …


I’m not going to argue with a brick wall.

Both are equally exploitable.

1 Like

Here’s a video of me changing the walkspeed on client after setting the walkspeed on the server. The client is actually able to change the value since the server will update the clients values, but the client can instantly change the values back. Servers are not safe in the sense that they have full control over the clients computer, but rather that they can store data safely without clients being able to read the data.

Edit: New video, last one was corrupted.

3 Likes

Sure, here:

2 Likes

This won’t do anything. I’m not even gonna test something as ridiculous as this, you can do that yourself and prove yourself wrong. Stop wasting my time.

The walk speed is only changed on client, and the server will not be able to detect it. So this will do nothing.

Also, even if you keep resetting walk speed to 1 on a loop on the server, it won’t work, since for performance reasons, if you try to set a property to its current value, it won’t replicate to any clients.

Please stop embarrassing yourself, test these things before you post them.

1 Like

because i heard that you need to disconnect events no?

Well, I’ve never had a problem with this. I work with Unity in C#. This is a known fact: the server has full control. I was unaware this was even possible here. I can only go off what I know to be true. You have made your point, and thank you for the clarification on this issue. However, the total toxicity of how you’re communicating is actually something to be embarrassed by; it screams entitlement. Your profile also states you are: “1000x developer. I am better than all of you.” Yet you stumble with simple basic tact. How else am I to take your replies as nothing more than troll-ish toxicity.

@ effbeecee Thank you for the clarification. Seeing is believing. I should not have assumed all platforms were the same..

Then don’t disconnect them …

Summary

abcdefghijklmnopqrstuvwxyz

1 Like