ServerScript only affecting LocalPlayer?

Hello there Developers, wondering if you can help out here.

I’ve been trying to figure out how to make a Local Script GUI be able to execute a Server Sided execution. It keeps affecting the Local Player and not the Desired Player.

If you can help out, much would be appreciated. Any questions will be answered and feedback is appreciated.
Local Script/Starter GUI that’s Enabled:

local playerService = game:GetService("Players")
local GUI = script.Parent.Parent.Parent
local players = playerService:GetPlayers()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = ReplicatedStorage:WaitForChild("ScDTestCD")

script.Parent.TextButton.MouseButton1Click:Connect(function()
	print(script.Parent.TextBox.Text)
	for i, v in pairs(players) do
		if v.Name == script.Parent.TextBox.Text then
			print(script.Parent.TextBox.Text)
			print("FOund them")
			if GUI.ScDTesting.Enabled == true then
				if GUI.ScDTesting.CDOne.Visible == true then end
				GUI.ScDTesting.CDOne.Visible = true
				GUI.ScDTesting.CDTwo.Visible = true
				GUI.ScDTesting.TestingFrame2.PlayerName.Text = script.Parent.TextBox.Text
				event:FireServer(script.Parent.TextBox.Text)
			else
				GUI.ScDTesting.Enabled = true
				GUI.ScDTesting.TestingFrame1.PlayerName.Text = script.Parent.TextBox.Text
				event:FireServer(script.Parent.TextBox.Text)
			end
		end
	end
end)

Local Script in GUI after it’s found a player and gives options on what to do:

--Make it Appear for Multiple Users Selected

script.Parent.CDOne.MouseButton1Click:Connect(function()
	script.Parent.TestingFrame1.Visible = true
	script.Parent.TestingFrame2.Visible = false
end)

script.Parent.CDTwo.MouseButton1Click:Connect(function()
	script.Parent.TestingFrame1.Visible = false
	script.Parent.TestingFrame2.Visible = true
end)

-- Handling Events

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Terminate = ReplicatedStorage:WaitForChild("ScDTerminateCD")
local Slowdown = ReplicatedStorage:WaitForChild("ScDSlowDownCD")

script.Parent.TestingFrame1.Terminate.MouseButton1Click:Connect(function()
	local player = script.Parent.TestingFrame1.PlayerName.Text
	Terminate:FireServer(player)
end)

script.Parent.TestingFrame2.Terminate.MouseButton1Click:Connect(function()
	local player = script.Parent.TestingFrame2.PlayerName.Text
	Terminate:FireServer(player)
end)

script.Parent.TestingFrame1.Slowdown.MouseButton1Click:Connect(function()
	local player = script.Parent.TestingFrame1.PlayerName.Text
	Slowdown:FireServer(player)
end)

script.Parent.TestingFrame2.Slowdown.MouseButton1Click:Connect(function()
	local player = script.Parent.TestingFrame2.PlayerName.Text
	Slowdown:FireServer(player)
end)

Server Script that handles the events (Where the problem is, that isn’t affecting the desired player, but affecting the player who made the submission:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local playerService = game:GetService("Players")

local Testing = ReplicatedStorage:WaitForChild("ScDTestCD")
local Terminate = ReplicatedStorage:WaitForChild("ScDTerminateCD")
local Slowdown = ReplicatedStorage:WaitForChild("ScDSlowDownCD")

Testing.OnServerEvent:Connect(function(playername)
	print(playername)
	print("Is Being Affected ^")
	local player = workspace:FindFirstChild(playername.Name)
	if workspace:FindFirstChild(playername.Name) then
		print(playername.Name)
		local part = game.ReplicatedStorage.Part:Clone()
		part.Parent = player
		local weld = Instance.new("WeldConstraint")
		weld.Parent = player
		weld.Part0 = part
		weld.Part1 = player.HumanoidRootPart
		part.Position = player.HumanoidRootPart.Position
	end
end)

Terminate.OnServerEvent:Connect(function(playername)
	local player = workspace:FindFirstChild(playername.Name)
	if workspace:FindFirstChild(playername.Name) then
		player.Humanoid.Health = 0
	end
end)

local On = false
Slowdown.OnServerEvent:Connect(function(playername)
	local player = workspace:FindFirstChild(playername.Name)
	if workspace:FindFirstChild(playername.Name) then
		if not On then
			On = true
			player.Humanoid.WalkSpeed = 1
		else
			On = false
			player.Humanoid.WalkSpeed = 16
		end
	end
end)
1 Like

on server event gives you the player instance of the player who fired the event so it would be this instead

Testing.OnServerEvent:Connect(function(playerWhoFired, player)

and change this

event:FireServer(script.Parent.TextBox.Text)

to this

event:FireServer(v)

and the part where u check for players character in workspace to this

if workspace:FindFirstChild(player.Name) then

oh and the part where u get the players it would only be a list of players when the localplayer joined so u change it to this instead

	for i, v in pairs(playerService:GetPlayers()) do

and to mention youre using remote events without checking and validating the player who fired it. that means an exploiter can just fire them easily i suggest you rewrite your scripts to have some sort of anti cheat

I am gonna add a checking for group for both the local script and server script, just for now I’m working on the actual findings lol. But let me try those solutions.

Even with those fixes, it does not work sadly. But ima keep trying with print to see where they end up going and go from there.

Found out why it wasn’t working.

Even though I’m searching for the player already with GetPlayers, apparently I need to use that in the fire event as well. No clue why or what was the reason even though I confirmed already it’s a player, it just worked.