This script is inside the part. The script is :
local waves = game.workspace.Tsunami["TsunamiParts"]
function onTouched(hit)
if waves.onTouched(hit)then
script.parent.Anchored = false
end
end
script.Parent.Touched:connect(onTouched)
This script is inside the part. The script is :
local waves = game.workspace.Tsunami["TsunamiParts"]
function onTouched(hit)
if waves.onTouched(hit)then
script.parent.Anchored = false
end
end
script.Parent.Touched:connect(onTouched)
The first problem is on line five where you consider onTouched to be a property of waves when there is no such property. In addition if you want to get all the children (parts) of a model, you use the GetChildren() method. In order to anchor the part when any part in waves is touched, you would do something like this:
local waves = game.Workspace.Tsunami
function onTouched (hit)
if hit:IsDescendantOf(waves) then
script.Parent.Anchored = false
end
end
script.Parent.Touched:Connect(onTouched)
In the onTouched function, the script is first checking whether or not the part that touched the part is part of the waves. If it is, the part's Anchored property is set to false.
**What's the error: ** On line 5, you're calling a function "onTouched", as though it's a function of the TsunamiParts Model.
**What's the solution: ** I'd imagine that you're trying to see if the touching part (hit) exists, and if so, anchor the parent of the script. You can check if hit exists easily, by doing:
local waves = game.workspace.Tsunami["TsunamiParts"]
function onTouched(hit)
if hit and hit:IsDescendantOf(waves) then
script.parent.Anchored = false
end
end
script.Parent.Touched:connect(onTouched)
Line 5, you're basically saying "onTouched" is a children of waves.
local waves = game.Workspace.Tsunami["TsunamiParts"]
waves.Touched:connect(function(hit)
script.Parent.Anchored = false
end)
Doesn't work e.e
It seems like that should work but it's not e.e
try using woolhat's.
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
try change waves.onTpuched(hit) to waves:onTpuched(hit)
I have no idea why it is not working.
@dar I'll try.
onTouched is not a valid member of WedgePart