Do you think you could send a place file over or a video? It should be working.
It’s supposed to be script.Parent.Triggered:Connect(function()
not script.Parent:Connect(function()
Send me the script in text form so I can edit your script and fix it for you.
Hi!
What you gonna do is.
- Make sure that the player Character is a thing, that Humanoid.Health > 0 (that they’re alive)
- If they don’t have a Shirt(or Pants, whatever you try to equip), when they trigger the Prompt, insert a new shirt.
- Now change their current shirt to the shirt id.
-- Normally I would combine some of the if statements. Like "if Humanoid and Humanoid.Health > 0 then". But I kept it very simple so you can find any errors that might occur. :slight_smile:
ProximityPrompt.Triggered:Connect(function(Player)
local leaderstats = Player:FindFirstChild("leaderstats")
if leaderstats then -- Makes sure that they have leaderstats
local Money = leaderstats:FindFirstChild("Money")
if Money then
if Money.Value > PriceOnAccessory then
local Character = Player.Character
if Character then -- If their character is not there in the first place, then they shouldn't be able to activate the prompt anyway. So no need to use "Player.CharacterAdded:Wait()", which will wait for the character to be a thing.
local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
if Humanoid then
if Humanoid.Health > 0 then
Money.Value -= PriceOnAccessory
local Shirt = Character:FindFirstChildWhichIsA("Shirt")
if not Shirt then
Shirt = Instance.new("Shirt")
Shirt.Parent = Character
end
Shirt.ShirtTemplate = AccessoryID
else
warn(Player.Name.." humanoid is dead")
end
else
warn(Player.Name.." humanoid not found")
end
else
warn(Player.Name.." character not found")
end
else
warn(Player.Name.." did not have enough money")
end
else
warn(Player.Name.." did not have money value-object")
end
else
warn(Player.Name.." did not have leaderstats folder")
end
end)
Hope this helped out! I did only take into account that you wanted to equip a shirt.
Holy crap you went bonkers with the lines
As stated in the reply, this is to make it print every error that might occur for OP.
But he’s also right, Also this is a much more professional script that also reconsiders all the possible errors
robloxapp-20220504-1942212.wmv (1.0 MB)
This is with your script and changed everything it needs(id, price etc)
And what is the issue you say?
Edit: What does the output say?
It does not change the shirt to the shirt i wanted to
edit: it says nothing
looks like no one noticed but your shirt and pant named as “Clothing”
find the shirt and pants by class not by name
script.Parent.Parent.ProximityPrompt.Triggered:Connect(function(plr)
local shirt = script:FindFirstChildOfClass("Shirt")
local pants = script:FindFirstChildOfClass("Pants")
plr.leaderstats.Money.Value += -50
if shirt and pants then
plr.Shirt.ShirtTemplate = shirt.ShirtTemplate
plr.Pants.PantsTemplate = pants.PantsTemplate
end
end)
Please go ahead and check the output panel.
Alr I’mma just make you a simple script
I usually use
FindFirstChildWhichIsA
But OfClass is also a option.
The :IsA()
function finds item by its class name, (still not sure they look exactly the same)
so you can use both FindFirstChildWhichIsA
and FindFirstChildOfClass
it still doesnt work, it has the same problem
Please go ahead and check the output panel.
i did, and it says nothing. Like i said very wierd