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

(solved) Unable to cast string to bool?

nvm I fixed it buy only adding one thing Hello, I have a rc car ai that senses if it touches something. If it touches something it plays a hit sound. But It doesn't want to work. I get the error Unable to cast string to bool. Can anybody help?

--Play sound script
local debounce = false

script.Parent.Touched:connect(function(hit)
if not debounce then
debounce = true
if(hit.Parent:FindFirstChild("MeshPart","Part","UnionOperation","WedgePart")~=nil)then
local sound = script.Parent.Hit --Removed space before end quotation mark
sound:Play()
wait(1.6)
end
debounce = false
end
end)

4 comments

0

This my answer

0

This my answer

0

This my answer

0

what?

1 answer

✓ Accepted answer

Hi, you need to add true.

 --Play sound script
 local debounce = false
 True = true
 script.Parent.Touched:connect(function(hit) = True
 if not debounce then
 debounce = true
 if(hit.Parent:FindFirstChild("MeshPart","Part","UnionOperation","WedgePart")~=nil)then
 local sound = script.Parent.Hit =          <------ Here add song --Removed space before end 
 quotation mark
 sound:Play()
 wait(1.6)
 end
 debounce = false
 end
 end)

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