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

(solved) Unable to cast string to bool?

Asked by 3 years ago
Edited 3 years ago

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)
0
This my answer badimo3456p 114 — 3y
0
This my answer badimo3456p 114 — 3y
0
This my answer badimo3456p 114 — 3y
0
what? squidiskool 208 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

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

Answer this question