Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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)
Ad

Answer this question