In my game, the player can press the Q key to do a dodge roll, which is supposed to turn their player into the ForceField material, and then back to plastic. In studio, this works perfectly fine, but in the game itself, the forcefield material isn’t showing up.
I have tested with friends, in one situation one of my friends had the intended effect, but another one had only their arms turn forcefield.
I have tried setting player material to forcefield while in game by using console, and it still turned invisible. I tried setting player torso to white, and it sometimes made the forcefield show, but it wasn’t consistent. No error messages or anything in console. Resetting does not change it. This is not a local script, it’s fired by remote event.
This is my code:
local character = player.Character
local humanoid = character.Humanoid
for i,child in pairs(character:GetChildren()) do
if child:IsA("Part") then
child.Material = Enum.Material.ForceField
end
if child:IsA("Accessory") then
child.Handle.Material = Enum.Material.ForceField
end
end
local character = player.Character
local humanoid = character.Humanoid
for _, obj in pairs(character:GetDescendants()) do
if obj:IsA("BasePart") then
obj.Material = Enum.Material.ForceField
end
end
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
for _, desc in pairs(character:GetDescendants()) do
if desc:IsA("Attachment") then
desc:FindFirstAncestorWhichIsA("BasePart")
desc:FindFirstAncestorWhichIsA("BasePart").Material = Enum.Material.ForceField
elseif desc:IsA("Accessory") then
desc:WaitForChild("Handle").Material = Enum.Material.ForceField
end
end
Does this work? It’s slightly hacky but it should allow for everything to load before attempting to set the material of the character’s parts to forcefield. Also this example is a local script but if you want this to replicate across the entire server to each client then you’ll need to perform these operations within a server script.
This didn’t work either, I tried it with both a local script and a server script, but the player was still invisible. I’m starting to think this is an issue with either Roblox, or something else entirely.
I decided to try testing the Microsoft store Roblox app, and it works. It still doesn’t work for the Roblox website, but when I join and play the game using the app, I can see the forcefield effect.
I tried switching to R15, and it still only works half of the time, and the head doesn’t have any problems when it does work. For some reason it seems to always show while playing using the Roblox app from the Microsoft store, but not while using the site. Should I just file a bug report?
I’ve been having a similar issue, and I believe at this time it’s more than likely not something wrong with your code, but something being up on Roblox’s end.
I’m doing a dodge system as well, and everything works on studio but, at random intervals, things don’t work in the game.
Studio:
In-game:
My code similarly just sets the material on a character’s parts to force field, but I include accessories and store it just to make sure when the dodge ends, everything’s back to normal.
local characterParts = player.Character:GetChildren()
local materialTable = {}
for i = 1,#characterParts do
if characterParts[i].ClassName == "Accessory" then
materialTable[characterParts[i].Name] = {characterParts[i].Handle.Material, "Accessory", characterParts[i].Name}
characterParts[i].Handle.Material = Enum.Material.ForceField
elseif characterParts[i].ClassName == "MeshPart" then
materialTable[characterParts[i].Name] = {characterParts[i].Material, "MeshPart", characterParts[i].Name}
characterParts[i].Material = Enum.Material.ForceField
elseif characterParts[i].ClassName == "Part" then
materialTable[characterParts[i].Name] = {characterParts[i].Material, "Part", characterParts[i].Name}
characterParts[i].Material = Enum.Material.ForceField
end
end
I think in the interest of getting this fixed, it’d make the most sense to file a bug report as you said. I wish I could provide some more useful info, but this just really looks like something I can’t do anything about.