I am making a pet gamepass feature for a game. I made a “Show Pets” button. For some reason, it won’t work. The event fires because the button color changes from green to red, but the pets do not become invisible. The pets are not models. I know it is possible because when I directly reference my character in the game, the pet transparency goes from 0 to 1 and it becomes invisible. Also, there are no errors in the output. The script is located in StarterGui under an image button. Here is the code:
Thanks for your help!
local value = true
repeat wait() until game:IsLoaded()
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
character = player.CharacterAdded:wait()
end
script.Parent.MouseButton1Down:Connect(function()
if value == true then
value = false
script.Parent.ImageColor3 = Color3.new(1, 0, 0)
character.Doge.Transparency = 1
else
value = true
script.Parent.ImageColor3 = Color3.new(0.231373, 1, 0)
character.Doge.Transparency = 0
end
end)
repeat task.wait() until game:IsLoaded() task.wait(1)
local plr = game.Players.LocalPlayer
local char = plr.Character
local value = true
script.Parent.MouseButton1Down:Connect(function()
if value == true then
value = false
script.Parent.ImageColor3 = Color3.new(1, 0, 0)
character.Doge.Transparency = 1
else
value = true
script.Parent.ImageColor3 = Color3.new(0.231373, 1, 0)
character.Doge.Transparency = 0
end
end)
Not saying this will work you just had a lot of unneeded stuff typed.
local Value = true
repeat wait() until game:IsLoaded()
local Players = game:GetService("Players")
if script:IsA("Script") then print("Running on server") end
local Player = Players.LocalPlayer
local Character = Player.Character
Pets = {[1] = "Doge"} -- First index is doge
Index = 1
script.Parent.MouseButton1Down:Connect(function()
if Value == true then Value = false script.Parent.ImageColor3 = Color3.new(1, 0, 0); Character[Pets[Index]].Transparency = 1 else Value = true script.Parent.ImageColor3 = Color3.new(0.231373, 1, 0) Character[Pets[Index]].Transparency = 0 end
end)
repeat task.wait() until game:IsLoaded() task.wait(1)
local plr = game.Players.LocalPlayer
local char = plr.Character
local value = true
script.Parent.MouseButton1Down:Connect(function()
if value == true then
value = false
script.Parent.ImageColor3 = Color3.new(1, 0, 0)
--char.Doge.Transparency = 1
elseif value == false then
value = true
script.Parent.ImageColor3 = Color3.new(0.231373, 1, 0)
--char.Doge.Transparency = 0
end
end)
Just took this into studio, works perfectly fine so idk what youre talking about mate.
question, is doge an accessory? If is you have to access the basepart that it has.
The basepart is called handle. Also it wont show serverside hoping you already know that.
Is doge the actual name and is it actually in the character by time youre checking? Cuz I can run this on my mesh and itll work perfectly fine there has to be some like specific reason to why its not working