Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-3

Chatted Script Help?

Asked by 8 years ago

Hello, I am working on a script that would allow the owner of a game say a in-game message and it will change the stats of the tycoons. It is a game owner command. Anyways this is what I got so far and it is not working.

a = game.Workspace["berezaa's Tycoon Kit"]
Users = {"CallMeDonaldTrump", "NameHere"}           
player=game.Players.LocalPlayer
player.Chatted:connect(function(msg)
if msg=="Owner" and player.Name==Users then
a["Bright red"].Cash.Value = 999999999
a["Bright green"].Cash.Value = 999999999
a["Bright blue"].Cash.Value = 999999999
a["Bright yellow"].Cash.Value = 999999999
end 
end)            
1
Try avoid using other people's scripts unless you are learning from them, learning from and using are very different. The only thing that appears wrong with this script is nothing, I think the issue is that Cash and Value don't exist. There is this awesome tool called output which will most likely help you fix any errors or nullpointers(trying to access something that doesn't exist) dragonkeeper467 453 — 8y
0
To view output go to view in the top bar of studio then click on the output button, you should also see many other things like explorer, properties, and more! dragonkeeper467 453 — 8y
0
Well, I do have the output out and nothing showed up in it. However I did find the issue, I just removed the "and player.Name==Users" and "Users = {"CallMeDonaldTrump"} and it worked CallMeDonaldTrump 5 — 8y
0
ok cool, keep using other peoples scripts, thatll get you far in life dragonkeeper467 453 — 8y
1
Lmaooooo epiclightining 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

It is best recommended to learn scripting and not work off of a model you found online. You could get infected or get a while true do end (A sample loop that can break your game.). One resource is here: https://developer.roblox.com/

Now, On line 5, you compared a string value with a table value full of strings. Of course, Names can't be tables.

If you want to check if a value given is in a table, there would be multiple options, but the main thing is that most would use a for loop. A for loop runs for a specific amount, be numbers or the amount in a list (or table). My version

function checkvalue(table1,val)
    for _,v in pairs(table1) do
        if v==val then
            return v
        end
    end
    return false
end

if checkvalue(table1,val) then
    print(checkvalue(table1,val))
else
    print('Can not find value.')
end
Ad

Answer this question