Material not changing from forcefield back to plastic

  1. What do you want to achieve? when using my quantum dash ability the player should turn purple, their material changes from plastic to forcefield, following the script the material should change back to plastic.

  2. What is the issue? the script works fine but the material doesn’t change
    video:

  3. What solutions have you tried so far? I tried a few things to change the material and nothing has worked so far.

I used 2 scripts:
LocalScript (first script in StarterCharacterScripts):

local UIS = game:GetService("UserInputService")
  
UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.X then
	    script.Fire:FireServer()
    end
end)

ServerScript (child of LocalScript above)

local enabled = true

script.Parent.Fire.OnServerEvent:Connect(function(player)

if not enabled then return end

enabled = false

local char = player.Character
local children = char:GetChildren()

char.Humanoid.WalkSpeed = 100

for i, v in pairs(children) do
	if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then
		v.Transparency = 0.5
		v.Material = "ForceField"
		v.BrickColor = BrickColor.new("Bright violet")
	end
end

wait (5)

char.Humanoid.WalkSpeed = 16

for i, v in pairs(children) do
	if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then
		v.Transparency = 0.5
		v.Material = "Plastic"
		v.BrickColor = BrickColor.new("Light orange")
	end
end

wait (5)

enabled = true

end)

any help is appreciated!

1 Like

You forgot the change the transparency back, here you go!

local enabled = true

script.Parent.Fire.OnServerEvent:Connect(function(player)

if not enabled then return end

enabled = false

local char = player.Character
local children = char:GetChildren()

char.Humanoid.WalkSpeed = 100

for i, v in pairs(children) do
	if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then
		v.Transparency = 0.5
		v.Material = "ForceField"
		v.BrickColor = BrickColor.new("Bright violet")
	end
end

wait (5)

char.Humanoid.WalkSpeed = 16

for i, v in pairs(children) do
	if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then
		v.Transparency = 0
		v.Material = "Plastic"
		v.BrickColor = BrickColor.new("Light orange")
	end
end

wait (5)

enabled = true

end)
2 Likes

oh my god- thank you so much I hadn’t noticed that!

1 Like