Changing material of model in workspace based on player's level

I’m not sure how to approach changing the material in a portal model whenever the player’s level gets high enough to use it. Every level increase of the player activates an additional portal which will turn the portal material from plastic to neon and enable teleportation when the player touches the portal.

I’ve been searching everywhere I can think of but I can’t find much except creating simple instances for players in local scripts…

This is my local script in the teleport models, but I can’t think of how I can make it run since it will not run local scripts from workspace.

Thanks for any advice!

local TeleportService = game:GetService("TeleportService")
local Place = 965894514
local Level2Telport = script.Parent
local player = game.Players.LocalPlayer
local level = player.PlayerInfo:WaitForChild("Level")

if level >= 2 then
	for i,v in pairs (Level2Telport:GetChildren()) do --get all children from model
		if v:IsA("BasePart") and v.Name == "light" then --check childrens name and classname
			v.Material = "Neon"
		end
	end
	Level2Telport.Telepad.Transparency = .3
	
end

	
	--teleports if touched and player level >= 2
	script.Parent.Touched:connect(function(hit)
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if player and level >= 2 then
				TeleportService:Teleport(Place, player)
			end
		end)
	

Portal-Question

Reference the LocalScript inside StarterPlayerScripts instead, and change your Level2Teleport variable to where it is inside the workspace & it should fix it

That goes for your script.Parent.Touched Event as well

1 Like

Awesome! That makes perfect sense! Sometimes I cannot see the forest through the trees. Thank you!