Decal Wont :Destroy()

Hello Everyone, currently im working on a teleporter and the part im having an issue on is deleting a decal on a part when a number value in workspace has a value of 2 or higher. Its a very simple script that works in a normal script, but for some reason not in a local script. I need it to work in a local script because you have to buy the teleporter (which makes the value 2) so not everyone can just walk through.

If anyone could assist with this that would be amazing.
Heres the very simple script:

if game.Workspace.AreaValue.Value >= 2 then
		game.Workspace.Island1.TeleportingStuff.PortalArea1To2.InsidePortal.Decal:Destroy()
end
1 Like

try this:

workspace.AreaValue.Changed:Connect(function()
    if (workspace.AreaValue.Value >= 2) then 
        workspace.Island1.TeleportingStuff.PortalArea1To2.InsidePortal.Decal:Destroy()
    end
end)
3 Likes

Doesnt seem to work still, also im just realizing i forgot to make it so theres less in the code, as i was moving things around. If this helps:

if game.Workspace.AreaValue.Value >= 2 then
	script.Parent.Decal:Destroy()
end
1 Like

Hey @tkuski08! How are you doing today?

Is it possible to show a screenshot of the structure of where everything is on Roblox Studio? For instance:

image

localscripts dont run in workspace, parent it to starterplayerscripts and it should work

If you want to do so when player has more then 2 coins to walk trough a wall then you need to have the local script in the starterplayerscripts for it to work you can’t have local scripts in parts

I’ve already tried that, but I will try it with your script as well!

Edit: nope, still doesnt work :confused:

@tkuski08 Mentioning you in case my message got away a bit above, haha

1 Like

Lol no worries i didnt forget you, it isnt letting me crop the image so heres the full thing smh.

Edit: Got It!
image

1 Like

Does the value start out as 2 when the player joins? If not, you need to instead put this into a loop so that it’s always checking until the value reaches 2. Only then can it run the code.

Example:

while true do
task.wait()
if game.Workspace.AreaValue.Value >= 2 then
	script.Parent.Decal:Destroy()
    break
end

P.S: Make sure that since it’s a LocalScript, it’s parented to a client service such as StarterPlayerScripts, StarterCharacterScripts, StarterGui, or StarterPack.

1 Like

While testing, the value is set at 3 when the player joins. Trying that right now!

Edit: Works!! Thank You very much!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.