I am trying to make a tycoon in which you can collect money by stepping on a brick .In single player everything works as intended, but when I try to use the “Team test” feature the GUI stops displaying how much money you have to collect. I do not know what is causing this, in both multiplayer and single player collecting money works fine, but the sign always says 0 even if you have more than 0.
Script that destroys parts:
wait(0.5)
destroyPart = script.Parent
givemoney = game.ServerStorage.moneytogive
players = game.Players:GetPlayers()
print(players)
destroyPart.Touched:Connect(function(hit)
print("h")
if hit.BrickColor == BrickColor.new("Magenta") then
accessory and other parts in the map.
local moneyToGive = hit:FindFirstChild("MoneyToGive")
givemoney.Name = "moneytogive"
givemoney.Value = givemoney.Value + moneyToGive.Value
hit:Destroy()
end
end)
script for part that gives money:
local ServerStorage = game:GetService("ServerStorage")
debounce = false
script.Parent.Touched:Connect(function(hit)
wait()
local moneyToGive = ServerStorage:FindFirstChild("moneytogive")
local Character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
if debounce == false and Humanoid ~= nil and player.Team == game.Teams["Purple Tycoon"] then
debounce = true
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + moneyToGive.Value
moneyToGive.Value = 0
wait(4)
debounce = false
end
end)
script for gui that displays how much money you have:
wait(1)
text = script.Parent
local ServerStorage = game:GetService("ServerStorage")
local money = ServerStorage:FindFirstChild("moneytogive")
money:GetPropertyChangedSignal("Value"):Connect(function()
text.Text = money.Value
end)
(btw this one is a localscript)