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)