Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does my script work in local server and not roblox server?

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?

8 comments

0

The DialogChoiceSelected event does not work in FilteringEnabled. It basically doesn't work anymore. You will need to create custom dialogues using GUIs.

0

is there a way to turn FilteringEnabled off?

0

no FE is always on because of the update, even if you turn it off

0

So I dont need this script whatsoever?

0

That is correct, buddyo. You're gonna have to make your own dialog GUI as incapaz said.

1

dang I just watched a vid over this, theres a load of scripting involved. this is gonna be a fun project lol

1

Lol. Good luck with it though, dude.

1

thanks ima need a lot more than luck this seems like a huge pain not gonna lie lol

2 answers

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! :)

1 comment

0

please read my comment

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.