Heyo Bro! You need to pass the localPlayer in the trigger, because the source does not exist on the server-side
--Server Side
function VoteSystem(title)
outputChatBox("Ghor'e Keshi Shodu Shod! Ba Dasture [/sherkat] Dar Ghore Keshi Sherkat Konid!")
end
addEvent("ElameShorueGhore", true)
addEventHandler("ElameShorueGhore", resourceRoot, VoteSystem)
function getrp( source, commandName )
randomP = getRandomPlayer()
triggerClientEvent(source, "getRandPlayer", source, randomP)
end
addEvent("StartRandom", true)
addEventHandler("StartRandom", resourceRoot, getrp)
-- Client Side
function dxUI(randomP)
ui["BG"] = dxDrawImage(x*741,0,x*619,y*487,"files/BG.png")
ui["title"] = dxDrawText(title, 0, y*70, x*1340, 0, tocolor(255, 255, 255, 255), 1, titleFont, "right")
ui["playerWon"] = dxDrawText(tostring(getPlayerName(randomP)), x*860, y*242,0,0, tocolor(255, 255, 255, 255), 1, playerFont)
end
addEvent("getRandPlayer", true)
addEventHandler("getRandPlayer", root, dxUI)
function ghore(CMD, ...)
if (ghoreStatus == 0) then
ghoreStatus = 1
local EnteredTitle = table.concat ( { ... }," " )
title = tostring(EnteredTitle)
addEventHandler("onClientRender", getRootElement(), dxUI)
triggerServerEvent("ElameShorueGhore", root)
triggerServerEvent("StartRandom", root, localPlayer)
end
end
addCommandHandler("ghore", ghore)
I redid the code, code below :
--Server Side
local rPlayer
function getrp( source, commandName )
randomP = getRandomPlayer()
rPlayer = randomP
end
addEvent("StartRandom", true)
addEventHandler("StartRandom", root, getrp)
addCommandHandler('ghore',
function(player, cmd, ...)
if ghoreStatus == 0 then
ghoreStatus = 1
local EnteredTitle = table.concat ( { ... }," " )
title = tostring(EnteredTitle)
triggerEvent("StartRandom", root, localPlayer)
outputChatBox("Ghor'e Keshi Shodu Shod! Ba Dasture [/sherkat] Dar Ghore Keshi Sherkat Konid!")
if rPlayer and title then
triggerClientEvent(root, 'receptRender', root, rPlayer, title)
end
end
end
)
-- Client Side
local randomP
local title
function dxUI()
--dxDrawImage(741,0,619,487,"files/BG.png")
dxDrawText(title, 0, 70, 1340, 0, tocolor(255, 255, 255, 255), 1, 'default', "right")
dxDrawText(tostring(getPlayerName(randomP)), 860, 242,0,0, tocolor(255, 255, 255, 255), 1, 'default')
end
function receptRender(rp, tt)
randomP = rp
title = tt
addEventHandler('onClientRender', root, dxUI)
end
addEvent('receptRender', true)
addEventHandler('receptRender', root, receptRender)