You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I would like to make an command that runs code on the server side.
What is the issue? Although the server is receiving the code, it is not running the code.
I tried firing “print(‘Hello’)” But doesn’t run. I know it is receiving the code. What is wrong here? There arent any errors being displayed…
What solutions have you tried so far? I confirmed that loadstring was enabled in server script service.
SERVER SCRIPT
script.Parent.Eval.OnServerEvent:Connect(function(plr, Text)
local token = "my token goes here, I'm not giving this away lol"
if script.Parent.Parent.Parent.TOKEN.Value == token then
print(Text)
loadstring(Text)
else
plr:Kick("\n \n Nice try. \n Code: Ungranted Access to Owner Commands")
end
end)
All help is appreciated!!!
P.S. Please also tell me if this is a security issue.
But you realise this is a VERY exploitable tool to enable?
You should look into validating the code being sent to the server (on the server) before running it - make sure it doesn’t affect other players - less you really don’t care and - well whatever.
Well old fashioned diagnosing to the rescue - PRINT!
Is the Client actually sending the request?
Is the Eval RemoteEvent being called?
Is the .TOKEN.Value reference correct? - try creating a hard reference to it outside of your Event
What is populating .TOKEN.Value?
local TOKEN = game.ScriptService:FindFirstChild("TOKEN",true) -- corrrect this as neccesarry
script.Parent.Eval.OnServerEvent:Connect(function(plr, Text)
print("Player",plr,"called Eval Event with value",Text)
if (TOKEN == nil) then print("Couldn't find TOKEN",TOKEN) return end
local token = "my token goes here, I'm not giving this away lol"
if TOKEN.Value == token then
print("Player",plr,"loadstring executed:",Text)
loadstring(Text)
else
print("Player",plr,"Failed Validation - Kicking")
plr:Kick("\n \n Nice try. \n Code: Ungranted Access to Owner Commands")
end
end)
Like I said before, everything is working except the loadstring. I checked it
Heres proof
if script.Parent.Parent.Parent.TOKEN.Value == token then
print("Here is the code being ran: " .. Text)
loadstring(Text)
else
plr:Kick("\n \n Nice try. \n Code: Ungranted Access to Owner Commands")
end
I meant - are you adding a value from the client so that you can validate the token somehow - otherwise your logic is literally a “if true == true” statement.
Well, I am doing this to make sure that the client didn’t just clone it. And also its verifying it from the server so if the client changes the value, it wont do anything.