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

Unable to cast value to Object Value. What is a good way of fixing this?

Asked by 4 years ago
Edited 4 years ago

I am trying to make a gui appear to the driver when the train touches a part.

script.Parent.Transparency = 1

script.Parent.Touched:Connect(function(hit)
    if hit.Name == "SensorTrain" then
        if hit.Parent.Parent.Parent.NextStop.Value == "Messestadt Ost" then
            local player = hit.Parent.Parent.Parent.Driver.Value
            game.ReplicatedStorage.GuiStationAppear:FireClient(player,"Stop")
        end
    end
end)

I fixed it by putting game.Players:FindFirstChild(hit.Parent.Parent.Parent.Driver.Value) into the code

0
You Clearly Did Not Read My Post You Idiot I Literally Told You Lfao. Read You Noob. I Said Remove The ToString. robloxrobloxepicxd -8 — 4y
0
i did it and I already tried it. Read the desc xxMVG_Fan8xxALT 1 — 4y
0
GG, you fixed it. SilentsReplacement 468 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

Just a little oopsie you did. If all the if conditions are met, it should be working. If it doesn't, show what the output prints and show me your Event Listener.

script.Parent.Transparency = 1

script.Parent.Touched:Connect(function(hit)
    if hit.Name == "SensorTrain" then
        if hit.Parent.Parent.Parent.NextStop.Value == "Messestadt Ost" then
            local player = hit.Parent.Parent.Parent.Driver.Value
            game.ReplicatedStorage.GuiStationAppear:FireClient(player,"Stop")
            print("Fired") -- If this doesn't print, your if conditions aren't met
        end
    end
end)
0
The Condition is true, but the problem is with the Driver Name thingy xxMVG_Fan8xxALT 1 — 4y
0
wait. I could put game.Players:FindFirstChild(hit.Parent.Parent.Parent.Driver.Value) as player xxMVG_Fan8xxALT 1 — 4y
0
Your answer helped me, so i have accepted it. Thanks :) xxMVG_Fan8xxALT 1 — 4y
Ad
Log in to vote
-1
Answered by 4 years ago

Are You Actually That Dumb?? Like What Does It Take To Make You Use Your Brain. Come On Bro I Have Faith In You Man You Can Do It Better.

game.ReplicatedStorage.GuiStationAppear:FireClient(tostring(player),"Stop")

Remove The ToString BeCause That Is What Breaks The Script. Next Time Use Ur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like that guy Friskyman321 121 — 4y
0
Are You Actually That Dumb?? Like What Does It Take To Make You Use Your Brain. Come On Bro I Have Faith In You Man You Can Do It Better. Uzixt 19 — 4y

Answer this question