So I am trying to find out if it is possible to call methods using :Connect()
I know it is possible by using :Connect(function()), however i wanna call the method right away
Yes, but you know how methods take self as the first argument? Well I’m trying to put that in through connect, to keep the code more readable and not have to readjust things everytime i change something in a fire event call.
ok so this is almost what ive been looking for but ill put an example of my code and the issue im having
function Tower:Spawn(player: Player, position: CFrame, towerName: string)
if TowerFolder:FindFirstChild(towerName) and player.PlayerStats.Cash.Value >= require(towerStats:WaitForChild(towerName)).Level1.UpgradePrice then
player.PlayerStats.Cash.Value -= require(towerStats:WaitForChild(towerName)).Level1.UpgradePrice
player.PlayerStats.TowersPlaced.Value += 1
so the issue here is that when it is called, all the values get messed up and theres errors because of it
example: the player is turned to some numbers, position to the player name and towername to nil
Is this function being called via server-script through a Remote Event? Because since you have more than 1 parameter, I’m pretty sure you’ll want to make an anonymous function when using the connection to pass them through (which is your issue). I searched up on it, and this post says the same.