New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Change mesh When touched, Can Anyone help?

Asked by 4 months ago
Edited 4 months 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 104 — 4mo
0
I tried something new, give it a shot Feahren 2005 — 4mo

1 answer

Log in to vote
0
Answered by
Feahren 2005 Moderation Voter Community Moderator
4 months ago
Edited 4 months 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 104 — 4mo
Ad

Answer this question