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

I'm making a command to give myself a stand but it doesn't seems to work. Anyone help?

This is my code right now:

local plr = game.Players.LocalPlayer
local chr = plr.Character
local replicatedstorage = game:GetService("ReplicatedStorage")
local standevent = replicatedstorage.StandChanger

plr.Chatted:Connect(function(msg, number)
	if msg == "!givestand "..number then
		if plr.Name == "QuanVo200" then
			standevent:FireServer(plr, number)
			end
	end
end)

And this is the event:

game.ReplicatedStorage.StandChanger.OnServerEvent:Connect(function(plr, number)
	plr.Data.Stand.Value = number
	plr:LoadCharacter()
end)

I expected it to change my Stand value into the number but it just doesn't work. Hope you can help. Thanks.

Edit: I started scripting a few months ago.

2 answers

✓ Accepted answer

Try this:

local plr = game.Players.LocalPlayer
local chr = plr.Character
local replicatedstorage = game:GetService("ReplicatedStorage")
local standevent = replicatedstorage.StandChanger

plr.Chatted:Connect(function(msg)
    if msg:lower():sub(1,11) == ("!givestand ") then
        if plr.Name == "quanvo200" then 
             local number = string.sub(msg, 12)
          standevent:FireServer(plr, number)
       end
    end
end)

You could also make an admin command for other players:

local plr = game.Players.LocalPlayer
local chr = plr.Character
local replicatedstorage = game:GetService("ReplicatedStorage")
local standevent = replicatedstorage.StandChanger
local admins = {
"quanvo200",
"OMGPROGUY",
"GoreDemonsHOT"
}

plr.Chatted:Connect(function(msg)
    if msg:lower():sub(1,11) == ("!givestand ") then
        if table.find(admins, plr.Name) then 
             local number = string.sub(msg, 12)
          standevent:FireServer(plr, number)
       end
    end
end)

also i recommend adding checks so it doesn't error:

game.Players.PlayerAdded:Connect(function(plr)
if table.find(admins, plr.Name) then 
local replicatedstorage = game:GetService("ReplicatedStorage")
local standevent = replicatedstorage.StandChanger
local admins = {
"quanvo200",
"OMGPROGUY",
"GoreDemonsHOT"
}

plr.Chatted:Connect(function(msg)
    if msg:lower():sub(1,11) == ("!givestand ") then
             local number = string.sub(msg, 12)
          standevent:FireServer(plr, number)
          end
       end)
    end
end)

8 comments

0

I'm new to the page so idek how to mark as answers.

0

I've never asked a question, so i don't know the layout, i think it's at the bottom.

0

When i used the command and checked for my value

0

it always says 0

0

There's probably something wrong with your events then since this SHOULD work.

0

I've tried like... a billion ways (not literally) to fix it. And i still can't.

0

You need to ask for help then using remote events / local script and server code.

0

Here's the screenshot of the error. http://prnt.sc/t39bkf | Edit: NVM  SORRY THAT WAS JUST A print() THING.

After 1 month of scripting i got alot better. I've made the script work myself. It's pretty easy actually. I don't even need an event. Still, thanks for your help. Edit: I'll mark your answer as the solution if other people have this kind of problem too.

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