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

Change mesh When touched, Can Anyone help?

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")'

2 comments

0

Im also really bad at typing

0

I tried something new, give it a shot

1 answer

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)

1 comment

0

Mesh Manager: http request failed, contentid: '921414861', exception: Temp read failed.

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