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

[SOLVED] How to use Object as String?

Asked by 4 years ago
Edited 4 years ago
mouse.Button1Down:Connect(function()
    if mouse.Target.Parent:FindFirstChild("Humanoid") then
        local arrestee = mouse.Target.Parent
        print(arrestee)
        local arrested = game.Players[arrestee]
        if arrested["TeamColor"] == BrickColor.new("Teal") or arrested["Settings"].innocent.Value == true then
            print("innocent")
        else
            game.ReplicatedStorage.Arrest:FireServer(arrestee)
        end
    end
end)

I am trying to us arrestee as a string, anyway to do that?

Edit: I solved the issue by putting the team checker part to a script:

if mouse.Target.Parent:FindFirstChild("Humanoid") then
        local arrestee = mouse.Target.Parent
        print(arrestee)
        game.ReplicatedStorage.Arrest:FireServer(arrestee)

1 answer

Log in to vote
0
Answered by 4 years ago

you would use .Name

mouse.Button1Down:Connect(function()
    if mouse.Target.Parent:FindFirstChild("Humanoid") then
        local arrestee = mouse.Target.Parent
        print(arrestee.Name)
        local arrested = game.Players[arrestee.Name]
        if arrested["TeamColor"] == BrickColor.new("Teal") or arrested["Settings"].innocent.Value == true then
            print("innocent")
        else
            game.ReplicatedStorage.Arrest:FireServer(arrestee)
        end
    end
end)
0
It didnt work BabanizPROcuk 49 — 4y
0
What error did you get? PureLiteStudio 80 — 4y
0
Unable to cast value to object BabanizPROcuk 49 — 4y
0
What line? PureLiteStudio 80 — 4y
View all comments (2 more)
0
Still gonna accept your answer since it solved the problem on my other script and you are the only one helped BabanizPROcuk 49 — 4y
0
5th line and 6th line BabanizPROcuk 49 — 4y
Ad

Answer this question