Nothing. (abcdefghijklmnopqrstuvwxyz)
try this
game.Workspace.Tower.Stage2.StartPlatform.Touched:Connect(function(hit)
local char = hit.Parent
local player = game.Players:GetPlayerFromCharacter(char)
local playerCash = player.leaderstats.Drops.Value
print("hi")
if not Floor1Won then
Floor1Won = true
playerCash += 5
end
end)
This was literally the script I sent at the very start.
The code that I posted would also work if this one worked.
The problem might be the Tower getting destroyed every 5 minutes therefore the event disconnects.
Doing a :WaitForChild(“Tower”) in a while loop might solve the problem.
Could you type it out please? I’m facing some issues.
Try this:
while task.wait() do
local connection
local function createConnection()
local Tower = game.Workspace:WaitForChild("Tower") -- Waiting for parts
local Stage = Tower:WaitForChild("Stage2")
local Part = Stage:WaitForChild("StartPlatform")
connection = Part.Touched:Connect(function(hit) -- Detecting when touched
local character = hit.Parent
if not character then return end -- Checking if hit.Parent exists
local player = game.Players:GetPlayerFromCharacter(character)
if not player then return end -- Checking if the found character actually belongs to a player
local playerCash = player.leaderstats.Drops
print("hi")
if not Floor1Won then
Floor1Won = true
playerCash.Value += 5 -- Increasing the value
end
end)
end
if not connection then
createConnection()
end
end
Okay, I’ll try it out and let you know as soon as I can.
There’s a few issues with this code block so I’ll go over each part
game.Workspace.Tower:WaitForChild("Stage2"):WaitForChild("StartPlatform").Touched:Connect(function(hit)
local char = hit.Parent
local player = game.Players:GetPlayerFromCharacter(char)
You’re not checking that player is actually there. Please do this, no seriously
if not player then return end -- some random part probably touched it
What I assume the main issue is this:
local playerCash = player.leaderstats.Drops.Value
print("hi")
if not Floor1Won then
Floor1Won = true
playerCash += 5
end
Many others have pointed this out already, you’ve created a variable to the current value in that value object, NOT the value object itself. What happens here is that when you go to add 5 to the value, you’re adding it to a number.
Again this is fairly easy to fix
- local playerCash = player.leaderstats.Drops.Value
+ local playerCash = player.leaderstats.Drops
print("hi")
if not Floor1Won then
Floor1Won = true
- playerCash += 5
+ playerCash.Value += 5
end
I tried it out, but it still doesn’t work.
I tried all of these too. This is weird.