How to give local player from local script to server script

  1. What do you want to achieve?
    For my local script to print(“Give 1000”) and print local player. Also I want my other script to get this information to start the script when it finds print(“Give 1000”) and use the local player information print to find what player clicked the button
  2. What is the issue?
    My local player isn’t scripted correctly, and I dont know how to fix it.
  3. What solutions have you tried so far?
    Google, using ai, rewrote my script, and I posted this on the dev forum but with not enough information to get anything done.
    My local script. Or the button script.
local Players = game:GetService("Players")
local playerGui = Players.LocalPlayer.PlayerGui
local button = playerGui:WaitForChild("Auction").GuiButton
local player = Players.LocalPlayer

button.MouseButton1Click:Connect(function()
	print("Give 1000")
	print(player)
end)

My server script

local messageToFind = "Give 1000"
local Players = game:GetService("Players")
local player = game.StarterGui.Auction.Hax1000.LocalScript.localscript:8

game:GetService("LogService").MessageOut:Connect(function(message, messageType)
	if messageType == Enum.MessageType.MessageOutput and message:find(messageToFind) then
		player.leaderstats.Jenny.Value = player.leaderstats.Jenny.Value + 1000
	end
end)

Heres the leaderstats.
image

1 Like

You would simply use RemotesEvents for this. However, your current setup of allowing the client to give money to the player will leave your game vulnerable to exploiters.

-- Client
RemoteEvent:FireServer(1000)
-- Server
RemoteEvent.OnServerEvent:Connect(function(player, amount)
   --...
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.