I am making a tower defense farm tower and it wont give me cash/credits every wave. If you dont know what a farm tower is, it is basicly a tower that gives money every wave just like a farm business. The tower is suppose to give the owner who placed the tower cash every single wave. There is no errors in the code. There is also suppose to be a billboardGui on the farm tower whenever the players give the cash, and I have made it but doesnt show it. Here is the first part of the script that is a module:
local map = workspace.Map:FindFirstChildOfClass("Folder")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local events = ReplicatedStorage:WaitForChild("Events")
local animateTowerEvent = events:WaitForChild("AnimateTower")
local wave = workspace.Info.Wave
local farmEvent = events:WaitForChild("FarmClient")
local SupplyCrate = {}
function SupplyCrate.SetUp(newTower, player)
wave.Changed:Connect(function()
if newTower:FindFirstChild("Config") and newTower.Config:FindFirstChild("Config") then
local config = newTower.Config.Config
if newTower and newTower:FindFirstChild("Humanoid") and newTower.Humanoid.Health > 0 and player then
animateTowerEvent:FireAllClients(newTower, "Attack")
farmEvent:FireAllClients(newTower)
script.Crate:Play()
player.Gold.Value += config.Money.Value
end
end
end)
end
return SupplyCrate
Here is the second part of the scripts:
local farmEvent = events:WaitForChild("FarmClient")
local function farm(tower)
if tower and tower:FindFirstChild("Humanoid") and tower.Humanoid.Health >= 0 and tower.HumanoidRootPart:FindFirstChild("CashGui") then
local farmText = tower.HumanoidRootPart.CashGui.CashText
farmText.Text = "$" .. tower.Config.Money.Value
farmText.Transparency = 0
farmText.UIStroke.Transparency = 0
wait(1.5)
farmText.Transparency = 1
farmText.UIStroke.Transparency = 1
end
end
--end of the script
farmEvent.OnClientEvent:Connect(function(tower)
if tower and tower:FindFirstChild("Humanoid") and tower.Humanoid.Health >= 0 and tower.HumanoidRootPart:FindFirstChild("CashGui") then
farm(tower)
end
end)
If you can I would also want you to try and help me how to make the billboardGui slowly go up into the air then fade out.