I feel like I make like 20 posts a day. game devving is soooo … usauugushfghgfdgjk killing me
anyways after successfully getting stuff to work on my last post, i IMMEDIATELY faced a new problem that google couldnt help me with
Footage here: https://youtu.be/T1HI2l3DOz0
Basically, buttons are supposed to turn white when they’re selected. I can’t quite do it in a local script since everything’s already hanging on by a thread and written by someone (me) who knows nothing about luascript. For some reason, despite all of google and devforum saying that’s how it’s supposed to be formatted, stuff just ain’t workin.
Any help appreciated :3
May I know why you put the local construct here?
I was worried it’d somehow affect other players, but I don’t think removing “local” would change it. I can try but I thought I did already
Don’t you know how the Local construct works? I advise you to look into this, and yes removing local may help there, specifically on lines with red underlining.
I feel really dumb now haha. It did remove the red underline and allow the script to continue working, however the background of the buttons did not change as intended.
Can you provide your script in printed form?
-- CHARACTER CUSTOMIZATION --
local CollectionService = game:GetService("CollectionService")
FelineParent = script.Parent
-- MORPH --
local Players = game:GetService("Players")
game.Players.PlayerAdded:Connect(function(plr)
local player = plr
game.ReplicatedStorage.Events.MorphEvent.OnServerEvent:connect(function(plr)
local oldCharacter = player.Character
local newCharacter = FelineParent.Feline:Clone()
newCharacter.HumanoidRootPart.Anchored = false
newCharacter:SetPrimaryPartCFrame(oldCharacter.PrimaryPart.CFrame)
player.Character = newCharacter
newCharacter.Parent = workspace
end)
end)
-- BODY PARTS --
game.ReplicatedStorage.Events.Torso1Event.OnServerEvent:connect(function(plr)
local Character = plr.Character
local Button = game:GetService("StarterGui").Menu.Frame1.BodyParts.Torso1
if Character.Torso1:HasTag("SelectedParts") then
CollectionService:RemoveTag(Character.Torso1, "SelectedParts")
Button.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
else
CollectionService:AddTag(Character.Torso1, "SelectedParts")
Button.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
end
end)
-- COLOR --
game.ReplicatedStorage.Events.ColorEvent1.OnServerEvent:connect(function(plr)
local Character = plr.Character
for i, BodyPart in pairs(CollectionService:GetTagged("SelectedParts")) do
BodyPart.Color = Color3.fromRGB(255, 0, 0)
end
end)```
try this
-- CHARACTER CUSTOMIZATION --
local CollectionService = game:GetService("CollectionService")
FelineParent = script.Parent
-- MORPH --
local Players = game:GetService("Players")
game.Players.PlayerAdded:Connect(function(plr)
local player = plr
game.ReplicatedStorage.Events.MorphEvent.OnServerEvent:connect(function(plr)
local oldCharacter = player.Character
local newCharacter = FelineParent.Feline:Clone()
newCharacter.HumanoidRootPart.Anchored = false
newCharacter:SetPrimaryPartCFrame(oldCharacter.PrimaryPart.CFrame)
player.Character = newCharacter
newCharacter.Parent = workspace
end)
end)
-- BODY PARTS --
game.ReplicatedStorage.Events.Torso1Event.OnServerEvent:connect(function(plr)
local Character = plr.Character
local Button = plr.PlayerGui.Menu.Frame1.BodyParts.Torso1
if Character.Torso1:HasTag("SelectedParts") then
CollectionService:RemoveTag(Character.Torso1, "SelectedParts")
Button.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
else
CollectionService:AddTag(Character.Torso1, "SelectedParts")
Button.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
end
end)
-- COLOR --
game.ReplicatedStorage.Events.ColorEvent1.OnServerEvent:connect(function(plr)
local Character = plr.Character
for i, BodyPart in pairs(CollectionService:GetTagged("SelectedParts")) do
BodyPart.Color = Color3.fromRGB(255, 0, 0)
end
end)
I’m not entirely sure what you changed, but it works, thank you so much! : D
You’re welcome!
Also, so you understand, I changed the path to the button. StarterGui is a Gui storage for all players, from where the Gui is taken when a player dies or logs into the game, so your script would work for everyone, but only after they Reset Character. Player has the PlayerGui property, which is responsible for the operation of the Gui for a specific player in real time.
-- BODY PARTS --
game.ReplicatedStorage.Events.Torso1Event.OnServerEvent:connect(function(plr)
local Character = plr.Character
--------------------------------------------------------------------------------
-- I CHANGED THIS
local Button = game:GetService("StarterGui").Menu.Frame1.BodyParts.Torso1 -- Old (Referring to the Gui repository) STARTER GUI
local ButtonChanged = plr.PlayerGui.Menu.Frame1.BodyParts.Torso1 -- New (Referring to a specific player and his real-time gui storage) PLAYER GUI
--------------------------------------------------------------------------------
if Character.Torso1:HasTag("SelectedParts") then
CollectionService:RemoveTag(Character.Torso1, "SelectedParts")
Button.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
else
CollectionService:AddTag(Character.Torso1, "SelectedParts")
Button.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
end
end)
Hope this helps you! Good luck!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.