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

How do i make a Chat command that when u say a String Value it executes a script?

Rn im trying to make a bleach type game but i was just trying to make chat commands that will work but it isnt and i have no clue why

Script to make said values:

local service = game:GetService("DataStoreService")
local datastore = service:GetDataStore("Stats")
game.Players.PlayerAdded:Connect(function(player)
	print'Joined'
	local datafolder = Instance.new("Folder",player)
	datafolder.Name = "Data Folder"

	local fruitvalue = Instance.new("StringValue",datafolder)
	fruitvalue.Name = "KeyWord"
	local rad = math.random(1,2)
	if rad == 1 then
		fruitvalue.Value = "Unleash"
	elseif rad == 2 then
		fruitvalue.Value = "Go"
	end
	local dee = Instance.new("StringValue",datafolder)
	dee.Name = "Zanpakuto"
	local rad = math.random(1,2)
	if rad == 1 then
		dee.Value = "Zangetsu"
	elseif rad == 2 then
		dee.Value = "Sword"
	end
	wait(.1)
	if not player:WaitForChild'Data Folder' then return end
	print'loaded data folder'
end)

Chat command local script in starter player:

local plr = game.Players.LocalPlayer
local key = plr.Data.KeyWord.Value
local sword = plr.Data.Zanpakuto.Value
local debounce = false

plr.Chatted:Connect(function(msg)
	if msg == key..", "..sword then
		print("Shinkai")
	end
end)

1 answer

✓ Accepted answer

Read both scripts, you got messed up variables. In first script you named your data folder "Data Folder", and in second you access it like plr.Data instead of plr["Data Folder"]. And your fruitvalue is random, it is "Go" or "Unleash". So if you want to chat command to work you need to know which of them is right in the moment, or you got to try both, and same for your sword value, its random, so to make it work you need to write to chat all possible variants, that means write to chat:

Unleash, Sword

or

Go, Sword

or

Unleash, Zangetsu

or

Go, Zangetsu

Change that random value system!.

1 comment

0

Bruv i didnt even realise that man thanks so much im so lazy :(

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