I have made a script where a model is put into the players character but when it is parented to the players character it goes invisible so i made a function where the model should be non transparent but it only runs when the player unequips the tool. Why is this happening?
local Player = game.Players.LocalPlayer
local Tool = script.Parent.Parent
local Events = game.ReplicatedStorage.Calls
local Character = Player.Character or Player.CharacterAdded:Wait()
local WeaponTool = game.ReplicatedStorage.Models["9mm Pistol"]
local Stats = require(script.Parent:WaitForChild("ModuleScript"))
local EquipAnimU = nil
local UnEquipU = nil
local UnEquipE = 0
local IdleAnimU = nil
local Equipped = false
script.Parent.Parent.Equipped:Connect(function()
if Equipped == false then
Equipped = true
local Character = Player.Character
local Humanoid = Character.Humanoid
EquipAnimU = Humanoid:LoadAnimation(script.Parent.Parent.Anims.Equip)
EquipAnimU:Play()
Events.ConnectM6D:FireServer(WeaponTool.BodyAttach)
Render() -- Function Call
wait(0.28)
script.Parent.Parent.Sounds.Slide1:Play()
wait(0.1)
script.Parent.Parent.Sounds.Slide2:Play()
wait(0.28)
IdleAnimU = Humanoid:LoadAnimation(script.Parent.Parent.Anims.Idle)
IdleAnimU:Stop()
if Tool.Parent == Character then
IdleAnimU = Humanoid:LoadAnimation(script.Parent.Parent.Anims.Idle)
IdleAnimU:Play()
elseif Equipped == true then
Tool.Parent = Player.Backpack
IdleAnimU:Stop()
EquipAnimU:Stop()
end
end
end)
script.Parent.Parent.Unequipped:Connect(function()
if UnEquipE == 0 and Equipped == true then
IdleAnimU:Stop()
EquipAnimU:Stop()
IdleAnimU = nil
UnEquipE = 1
local Character = Player.Character
local Humanoid = Character.Humanoid
UnEquipU = Humanoid:LoadAnimation(script.Parent.Parent.Anims.UnEquip)
UnEquipU:Play()
wait(UnEquipU.Length)
Events.DisconnectM6D:FireServer(Player.Character["9mm Pistol"])
UnEquipE = 0
Equipped = false
end
end)
function Render() -- Function
game:GetService("RunService").RenderStepped:Connect(function()
if Equipped == true then
for i, part in pairs(Character["9mm Pistol"]:GetChildren()) do
if part:IsA("MeshPart") then
part.LocalTransparencyModifier = 0
end
end
end
end)
end

6 comments
This is a localscript, right?
Yea
Try moving the function above the Equipped statement, I’m not sure if this is a runtime issue.
It does the same thing really confusing
Could you explain what it’s doing?
The function is getting all the parts in the model and turning there local transparency to 0, i put it on the equip segment but it only seems to call the function when unequipping