What I want to achieve is it will pick a new random value from the table once player chatted ‘/changeword’ but keeps getting the starting word
local words = {'no','ok','help','yes','daddy','come','here'}
game.Players.PlayerAdded:Connect(function(p)
local nallowedword = Instance.new('StringValue')
nallowedword.Name = 'Word'
nallowedword.Parent = p
local choosedword = words[Random.new(tick()):NextInteger(1,#words)]
nallowedword.Value = choosedword
print('Starting word: '..choosedword)
p.Chatted:Connect(function(chat)
if chat == '/changeword' then
nallowedword.Value = choosedword
print('Word changed to: '..choosedword)
end
if string.find(chat,nallowedword.Value) then
p:Kick('You said the word: '..nallowedword.Value)
end
end)
end)