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

Change mesh When touched, Can Anyone help?

Asked by 4 years ago
Edited 4 years ago

Concept: Change the mesh when a player touches the brick script:

function touched()
    Instance.new("SpecialMesh", script.Parent)
    script.Parent:WaitForChild(SpecialMesh)
    script.Parent.SpecialMesh.MeshID = "921414861"
end
script.Parent.Touched:Connect(touched)

EDIT: So i changed it to ("SpecialMesh") and now it says Infinite yield possible on 'Workspace.Part:WaitForChild("SpecialMesh")'

0
Im also really bad at typing Vortex_Vasne 89 — 4y
0
I tried something new, give it a shot Ziffixture 6913 — 4y

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

The parental argument of Instance.new() was deprecated, using it causes a lot of issues that are plain nuisances. For this case, it's caused an issue with referencing the Object. It's said that for now, too avoid these inconvenient problems, just declare the secondary argument outside the function.

Another note: You can also pin the allocation of the Instance within a variable, so that will be eaiser to work with as well.

local Part = script.Parent

function onTouch(hit)
    local sMesh = Instance.new("SpecialMesh"); sMesh.Parent = Part
    sMesh.MeshId = "rbxassetid://921414861"
end

Part.Touched:Connect(onTouch)
0
Mesh Manager: http request failed, contentid: '921414861', exception: Temp read failed. Vortex_Vasne 89 — 4y
Ad

Answer this question