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

Unable to cast ID value to a dummy through a textbutton?

Asked by 2 years ago

So pretty much I'm trying to make a textbox in which the player inputs a users name and it gets the ID and applies said ID to a dummy. I know how to get the ID, in fact it works like a charm for printing, however it gives me the error, "Unable to cast value to object" whenever I try to apply the ID to the Dummy. Here are both codes: Client/Local Script:

local Players = game:GetService("Players")
local textbox = script.Parent
textbox.ClearTextOnFocus = true
textbox.PlaceholderText = "Enter friend or random user's username"
local colorNormal = Color3.new(1, 1, 1)
local function onFocused()

    textbox.BackgroundColor3 = colorNormal
end
textbox.FocusLost:Connect(function(enterPressed, inputObject)
    if enterPressed then
        local text = textbox.Text
        local id = Players:GetUserIdFromNameAsync(text)
        game.ReplicatedStorage.dname:FireServer(id)
    end
end)

Server Script:

local dname = game.ReplicatedStorage:FindFirstChild("dname")
dname.OnServerEvent:Connect(function(player, id)
    print(id)
    game.workspace.Dummy.Humanoid:ApplyDescription(id)
end)

I've been searching of ways to fix this for hours now and I finally gave up and came to get help. If anyone knows why it isn't working I would be very grateful if you helped me out! Tysm!

1 answer

Log in to vote
0
Answered by
enes223 327 Moderation Voter
2 years ago

hey you! have you ever heard of enes? if you are in trouble, better call enes!

0
So are you going to help me or is this just like a troll? Because I got really excited someone finally responded, yet it was just this... CameUpFromNothing 37 — 2y
Ad

Answer this question