I’ve already achieved a good script and i’ve got it perfectly to my satisfaction, the only problem is, it works completely fine on the playtest, but it seems to freeze and not work in the real game.
my script is meant to do this:
i have a chattag when i join, it is {TEMPO}, and when i chat, my chat should look like this:
{TEMPO}Myusername: hello
then, when i hit the period numberpad button, it will switch this chattag from {TEMPO} to {ARCHER}
so my chat would look like this
{ARCHER}Myusername: hello
and then, hitting the button again will bring it back, and back and forth.
this works perfectly in the playtest, but when i publish it to the game it refuses to work, and it freezes my chattag to only the {TEMPO} tag. here are screenshots
this is the image of my playtest game. perfectly working as intended.
this is the ingame image. not switching!
what do i have to do to fix this?
here is my script:
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local TextChatService = game:GetService("TextChatService")
local switch = false;
local ownerTag = "<font color='rgb(255,146,37)'>{TEMPO}</font> ";
local owners = {7937493120}
local groupId = nil
UIS.InputBegan:Connect(function(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.KeypadPeriod and switch == false then
ownerTag = "<font color='rgb(255,146,37)'>{ARCHER}</font> ";
switch = true;
elseif input.KeyCode == Enum.KeyCode.KeypadPeriod and switch == true then
ownerTag = "<font color='rgb(255,146,37)'>{TEMPO}</font> ";
switch = false;
end
end)
TextChatService.OnIncomingMessage = function(message)
local properties = Instance.new("TextChatMessageProperties")
local textSource = message.TextSource
if textSource then
local player = Players:GetPlayerByUserId(message.TextSource.UserId)
local isOwner = false
local isInGroup = false
for i, v in pairs(owners) do
if v == player.UserId then
isOwner = true
break
end
end
if groupId and player:IsInGroup(groupId) then
isInGroup = true
end
if isOwner then
properties.PrefixText = ownerTag .. message.PrefixText
elseif isInGroup then
properties.PrefixText = "<font color='rgb(0,255,0)'>[MEMBER]</font> " .. message.PrefixText
end
end
return properties
end
this script is a localscript, located in the startergui folder
— also, i’ve tried moving the script around, turning it into a regular script, publishing the server a million times, nothing of my solutions work…
me neither!! the userid is completely correct too, no misspells
i have restarted my game quite the lot of times while publishing each time, too
there are no scripts that i think would clash with this one, i made sure of it
i’m… not sure at all, but it doesn’t show for me either
and part of the script works, the part where i gives me one constant chat tag, but it never switches over
in fact, the script doesn’t even work at all in a regular script
neither in studio nor ingame
is the error the same for other people, maybe try with an alt account and see if it works? im not much of an expert but similar thing happened in a game a while back where my name was the only one which didnt appear on the leaderboard, but worked on playtest so maybe just an issue with studio i guess… hope it gets fixed soon
So I’ve solved your problem but this is quite peculiar & I’m not sure its really your problem.
I had the same problem as you, when I play in studio it works fine but in the actual server it wouldn’t register. Eventually found the problem was that the period key on the keypad that should correspond to Keycode.KeypadPeriod was actually being registered as Keycode.Delete – But only when playing on server… very odd and I can’t tell you why that would be happening but I’ve added the corrected code below → When I look at the standard layout of a keypad I noticed the Period is the result when you hold shift and press the key, whereas delete is the standard function. You’re original script would work if you enable caps lock / hold shift
The caveat here is of course that switching function doesnt work in studio test. You can always account for test mode but thats beyond the scope here.
ETA: I left the print statement in so if you go in server play mode and open the developer console you should be able to see what your keypad period code is actually reigstering input as, incase yours is registering something different than Keycode.Delete
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local TextChatService = game:GetService("TextChatService")
local switch = false;
local ownerTag = "<font color='rgb(255,146,37)'>{TEMPO}</font> ";
local owners = {7937493120}
local groupId = nil
UIS.InputBegan:Connect(function(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.Delete then
if switch then
ownerTag = "<font color='rgb(255,146,37)'>{TEMPO}</font> ";
switch = false;
else
ownerTag = "<font color='rgb(255,146,37)'>{ARCHER}</font> ";
switch = true;
end
else
print(input.KeyCode)
end
end)
TextChatService.OnIncomingMessage = function(message)
local properties = Instance.new("TextChatMessageProperties")
local textSource = message.TextSource
if textSource then
local player = Players:GetPlayerByUserId(message.TextSource.UserId)
local isOwner = false
local isInGroup = false
for i, v in pairs(owners) do
if v == player.UserId then
isOwner = true
break
end
end
if groupId and player:IsInGroup(groupId) then
isInGroup = true
end
if isOwner then
properties.PrefixText = ownerTag .. message.PrefixText
elseif isInGroup then
properties.PrefixText = "<font color='rgb(0,255,0)'>[MEMBER]</font> " .. message.PrefixText
end
end
return properties
end
THIS ABSOLUTELY FIXED IT, for some reason when i put YOUR script in, THE KEYBIND FOR THE PERIOD ON THE NUMBEERPAD STARTED WORKING INSTEAD!! bizzare… THANK YOU SO MUCH FOR THE HELP!!!