script.Parent.DialogChoiceSelected:Connect(function(player, choice) if choice.Name == "Ca" then if player.leaderstats.Money.Value >= 1000 then player.leaderstats.Money.Value = player.leaderstats.Money.Value - 1000 player.TeamColor = BrickColor.new("Bright green") else --Whatever you want to happen if they don't have enough money end elseif choice.Name == "Maybe some other time" then --Blahblahblah end end)
not sure what edits to give it but when I go into the server and bring up the output log there aren't any detected errors. I'm betting its a simple solution that I'm not seeing since I'm not very adept at script making. In studio it does exactly what I want it to, pay 1000 money to switch teams but when I play on roblox server it doesnt seem to want to work. Do I need to add WaitForChild?
This is probably happening because you 1. Have Filtering Enabled on and 2. You aren't using remote events. I suggest you look into RemoteEvents AND RemoteFunctions. I'm not sure if this is the actual solution to your problem but it looks like it. And also, you should NEVER take or add money to a player through a localscript, that's why we use Remote Events. The reason why it works in Studio is because you're playing it locally, which means when you're subtracting or adding currency it's doing it for you locally. However, in a server. A player cannot communicate with the server because of Filtering Enabled. That's why RemoteEvents are helpful because they allow a user to send a request to the server. Hopefully I am explaining this right, and if I solved or answer your question please accept my answer! :)
amount = script.Parent.MoneyValue.Value wait_time = 10 -- change this to how long you want to wait x = script.Parent enabled = true function touch(hit) if not enabled then return end enabled = false local h = hit.Parent:findFirstChild("Humanoid") if h ~= nil then local p = game.Players:getPlayerFromCharacter(hit.Parent) local money = p.leaderstats.Money if p.TeamColor ~= BrickColor.new("Bright green") then money.Value = money.Value + amount script.Parent.MoneyValue.Value = 0 p.TeamColor = BrickColor.new("Bright green") x.Parent.Name = "Finished!" wait(wait_time) x.Parent.Name = "Complete Training: 1000" enabled = true end end end x.Touched:connect(touch)
So I found a work around with the scripts! Using this script I can make it change teams (As the team change will be based on a tier list) by paying the amount required. So instead of it being changed from the dialog script I just edited the job task script to change teams by paying a certain amount. Additionally you can only change teams if you are on the previous tier to prevent players from accidentally touching the bricks and losing a large amount of progress.