TTT Pointshop item help

Heyo guys.

I recently created a script for a halloween event on a TTT server on which I play. It makes you transparent (ghostly).
It works fine in singleplayer (added it to point shop and tested it) but when it comes to using it it on the server, it appears in the TTT pointshop but when equipped it does not work.

This is the code:

[lua]
ITEM.Name = ‘Ghostly Impression’
ITEM.Price = 2500
ITEM.Model = ‘models/props_c17/gravestone003a.mdl’

function ITEM:OnEquip(ply, modifications)
hook.Add(“TTTBeginRound”, ply:UniqueID() … “_h_ghost_opacity”, function()
ply:SetColor(Color(255, 255, 255, 200))
ply:SetRenderMode(RENDERMODE_TRANSALPHA)
end)
end

function ITEM:OnHolster(ply)
hook.Remove(“TTTBeginRound”, ply:UniqueID() … “_h_ghost_opacity”)
end

function ITEM:OnSell(ply)
hook.Remove(“TTTBeginRound”, ply:UniqueID() … “_h_ghost_opacity”)
end
[/lua]

Any and all help would be greatly appreciated.

(I’m kinda new to coding, so please forgive me for any obvious mistakes in the script. Also, apologies if this is the wrong section. I’m new to facepunch.)

[lua]function ITEM:OnEquip(ply, modifications)
hook.Add(“TTTBeginRound”, ply:UniqueID() … “_h_ghost_opacity”, function() – here the ply is still correct, since it is the ply from OnEquip.
ply:SetColor(Color(255, 255, 255, 200)) – Since this is called in the hook without args, there isn’t an ply now.
ply:SetRenderMode(RENDERMODE_TRANSALPHA)
end)
end[/lua]

The Problem in a nutshell.

As I said, I’m new to coding. I usually stick to the basic stuff. This is probably the only script I’ve made that I’m not 100% sure on. I’d need someone to explain a fix to me in detail, since LUA is still a foreign language to me. I’m just the guy that says random foreign words when he gets a chance. :stuck_out_tongue:

Use hooks on the item instead of making and removing them.

[lua]
ITEM.Name = ‘Ghostly Impression’
ITEM.Price = 2500
ITEM.Model = ‘models/props_c17/gravestone003a.mdl’

function ITEM:TTTBeginRound(ply, modifications)
ply:SetColor(Color(255, 255, 255, 200))
ply:SetRenderMode(RENDERMODE_TRANSALPHA)
end
[/lua]

After further testing, we’ve established that it works for a split second when the round starts, then reverts back to 100% opacity. It makes me think that something could possible be conflicting with it, but the only thing that the server has that I don’t have is SpecDM (!dm). SpecDM DOES make players transparent when they enter SpecDM, but I don’t see how that could directly conflict with my script. Any thoughts?

This is the error received:

[ERROR] addons/pointshop-master/lua/items/halloween/ghostlymodel.lua:1: attempt to index global ‘ITEM’ (a nil value)

  1. unknown - addons/pointshop-master/lua/items/halloween/ghostlymodel.lua:1

-nevermind-

Normal Pointshop or some custom vgui aa Advanced Pointshop, Pointshop 2 etc?
try adding ITEM = {} at the top.

You need to change map/restart the server. PointShop doesn’t work with live reloading.

Hey, you mentioned you have SpecDM

I recall we had some issues too with a thing that set player colour and if I recall, it’s because there’s a think function or hook in SpecDM to set colour

Find that via ctrl+f since I can’t remember off the top of my head where it is, and then just do a check or something for it

That seems plausible. I don’t want to risk breaking anything, so I might just scrap the idea and remove my script. :stuck_out_tongue: