How to make my tower defense farm give the owner the cash

I am making a farm tower in my tower defense and I need help on how to give the cash to only the owner. Here is the script I have so far:

local Players = game:GetService("Players")
local Farmer = script.Parent


local wave = workspace.Info.Wave
local attachment = Farmer.HumanoidRootPart.GUIattachment
local OwnerOfTower = Farmer.Config:WaitForChild("Owner")

local player = Players.LocalPlayer


wave.Changed:Connect(function()
	if player then
		player.Gold.Value += Farmer.Config.Money.Value
		attachment.Parent.Crate:Play()
		attachment.Particle.Enabled = true
		Farmer.HumanoidRootPart.GUIattachment.CashGui.TextLabel.TextTransparency = 0
		Farmer.HumanoidRootPart.GUIattachment.CashGui.TextLabel.UIStroke.Transparency = 0
                wait(1)
		Farmer.HumanoidRootPart.GUIattachment.CashGui.TextLabel.Text = Farmer.Config.Money.Value .. "$"
	end
end)

The script has no errors and I would be very happy if you can help me with this issue.
The OwnerOfTower is a value of the towers owner who placed it when the player PLACES the tower. The value is not there until the player places the tower.

1 Like

You’d have to manage towers on the server as client can’t securely give cash

3 Likes