Gui that when button is pressed runs server script My Localscript
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RemoteEvents.AddBounty:FireServer()
end)
My ServerScript
--Check Players
game.ReplicatedStorage.RemoteEvents.AddBounty.OnServerEvent:Connect(function()
local Players = game:GetService("Players")
local textbox = script.Parent.Parent.StarterGui.BountyGUI.Frame.SearchBox
for _, v in pairs(Players:GetPlayers()) do
if textbox.Text == v.Name then
print(v.Name.."Was found")
end
end
end)
if the searchbox.text is equal to a player's name shouldn't it print? I'm so confused.
UPDATE: Local
local Frame = script.Parent.Parent.Parent:WaitForChild('Frame')
local SearchBox = Frame:WaitForChild('SearchBox')
local ValueBox = Frame:WaitForChild('ValueBox')
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local RemoteEvents = ReplicatedStorage:WaitForChild('RemoteEvents')
local AddBountyEvent = RemoteEvents:WaitForChild('AddBounty')
script.Parent.MouseButton1Click:Connect(function()
AddBountyEvent:FireServer(SearchBox.Text, ValueBox.Text)
end)
Script
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local RemoteEvents = ReplicatedStorage:WaitForChild('RemoteEvents')
local AddBountyEvent = RemoteEvents:WaitForChild('AddBounty')
AddBountyEvent.OnServerEvent:Connect(function(PlayerWhoClicked, searchname, valueAmount)
local PlayerInPlayers = Players:FindFirstChild ( searchname )
local ValueOfBounty = Players:FindFirstChild ( valueAmount )
if PlayerWhoClicked.leaderstats.Money.Value >= valueAmount then
PlayerWhoClicked.leaderstats.Money.Value = PlayerWhoClicked.leaderstats.Money.Value - valueAmount
PlayerInPlayers.leaderstats.Bounty.Value = PlayerInPlayers.leaderstats.Bounty.Value + valueAmount
else if PlayerWhoClicked.leaderstats.Money.Value < valueAmount then
end
end
end)

2 comments
Does it give you any errors?
no