Jump to content

[Help] /try command


VParker

Recommended Posts

So my problem is that it shows this error: Script Error: try\try.lua:6: ')' expected near "tried" when i launch my try resource.. Can anybody help me what to do? Here's the script: 

 function try(plr)
    local chance = math.random(0,1)
    if chance == 1 then
        local playerName = getPlayerName
        local actiontext = string.sub (text,3)
        outputChatBox ( " .. getPlayerName .. " "tried" "  .. actionText .. " "and it worked!" , root, 0, 255, 0, true )
    else
        local playerName = getPlayerName
        local actiontext = string.sub (text,3)
        outputChatBox ( " .. getPlayerName .. " "tried" " .. actionText .. " "and it didnt work!" , root, 255, 0, 0, true )
    end
end 

Link to comment
function try(plr)
    local chance = math.random(0,1)
    if chance == 1 then
        local playerName = getPlayerName
        local actiontext = string.sub (text,3)
        outputChatBox ( getPlayerName .. "tried" .. actionText .. "and it worked!", root, 0, 255, 0, true )
    else
        local playerName = getPlayerName
        local actiontext = string.sub (text,3)
        outputChatBox ( getPlayerName .. "tried" .. actionText .. "and it didnt work!", root, 255, 0, 0, true )
    end
end 

Btw. you will have to fix your playerName/getPlayerName.

Edited by Bananovy
Link to comment

you can do

outputChatBox ( getPlayerName(plr) .. "tried" .. actionText .. "and it didnt work!", root, 255, 0, 0, true )

-- or

local name = getPlayerName(plr)
outputChatBox ( name .. "tried" .. actionText .. "and it didnt work!", root, 255, 0, 0, true )

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...