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

So, when I try to filter text it warns me with: "Unable to cast Instance to int64", can anyone help?

This is the coding for the remotes:

local Events = game.ReplicatedStorage.Events
local Filter = Events.Filter
local change = Events.Change
local namechange = game.ReplicatedFirst.ForRoleplay.NameChange
local texttofilter = namechange.RPName.Text
local textservice = game:GetService("TextService")

Filter.OnServerEvent:Connect(function(player)
	textservice:FilterStringAsync(texttofilter, player)
end)

change.OnServerEvent:Connect(function(player)
	local nametag = namechange:Clone()
	nametag.RPName.Text = texttofilter
	nametag.Parent = workspace:WaitForChild(player.Name).Head
end)

Coding from the localscript:

script.Parent.FocusLost:Connect(function()
	game.ReplicatedStorage.Events.Filter:FireServer()
	wait(3)
	game.ReplicatedStorage.Events.Change:FireServer()
end)

If anyone can help that would be appreciated!

1 answer

You need to get the UserId of the player

local Events = game.ReplicatedStorage.Events
local Filter = Events.Filter
local change = Events.Change
local namechange = game.ReplicatedFirst.ForRoleplay.NameChange
local texttofilter = namechange.RPName.Text
local textservice = game:GetService("TextService")

Filter.OnServerEvent:Connect(function(player)
    textservice:FilterStringAsync(texttofilter, player.UserId) -- This is how to get the userid 
end)

change.OnServerEvent:Connect(function(player)
    local nametag = namechange:Clone()
    nametag.RPName.Text = texttofilter
    nametag.Parent = workspace:WaitForChild(player.Name).Head
end)

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