#could someone help? everytime i touch the chest i should get 1 win but nothing is happening
1 messages · Page 1 of 1 (latest)
** You are now Level 4! **
Maybe try putting .OnServerEvent functions out of OnPlayerAdded function and make them global. And also use :WaitForChild in the variables
** You are now Level 3! **
i will try
but if i do onplayeradded everyone who join will get a win right
so i just replace all the OnServerEvents with OnPlayerAdded?
No I meant that you should make the .OnServerEvent functions global
Meaning put them outside of OnPlayerAdded function
Also you have to check if it's the exact player you want to add wins or else it is just gonna add wins to random players
Hmm
What is chest
btw im scripting for 2 weeks now so i dont really know things
Oh yea
chest is just a part
so i just put the wins.value in the powerleaderstats?
WinEvent.OnServerEvent:Connect(function(plr) plr.leaderstats.Wins.Value += 1 end)
alright
local Players = game:GetService("Players")
local PowerLeaderstats = game.ReplicatedStorage.PowerLeaderstats
local WinEvent = game.ReplicatedStorage.WinEvent
local function onPlayerAdded(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Power = Instance.new("IntValue")
Power.Name = "Power"
Power.Value = 0
Power.Parent = leaderstats
local Wins = Instance.new("IntValue")
Wins.Name = "Wins"
Wins.Value = 0
Wins.Parent = leaderstats
PowerLeaderstats.OnServerEvent:Connect(function()
Power.Value = Power.Value + 1
end)
WinEvent.OnServerEvent:Connect(function(plr)
plr.leaderstats.Wins.Value += 1
end)
end
Players.PlayerAdded:Connect(onPlayerAdded)
i will send ss so you can understand it better
Yea
I told you to put winevent function out
OHHH
i get it what's the problem
Local scritps doesn't works in workspace
its not in workspace tho
Ur prolly using a local script in a part that's in workspace
I'm always right 👽 😎
Put it in Starter character script or StarterPlayerScritps
ok
Wait is chest in workspace?
yes
Then replace local Chest = script.Parent with
local Chest = --the location of chest in workspace
Yes
still doesnt work 😔
starter character scripts
Copy and apste local script code
local WinEvent = game.ReplicatedStorage.WinEvent
local Chest = game.Workspace.Hitbox
Chest.Touched:Connect(function()
WinEvent:FireServer()
end)
Use :WaitForChild
Also is there any errors in output?
If yes then tell what is it
i will exploit on your game for infinite wins when you release it
nope
i dont think i will release it lol
He's technically right
its just for learning lua
Oh then it's alr
Yea
ok
Also detect if hitbox is being touched or not
local WinEvent = game.ReplicatedStorage.WinEvent
local Chest = game.Workspace.Hitbox
Chest.Touched:Connect(function()
WinEvent:FireServer()
print(1)
end)
Now see if it prints 1
If it does then local script is working fine
its printing
Does it print 1
yep
Then problem is in server script
Try printing 2 in the last line of OnPlayerAdded function
And see if it does prints
has anything changed from the first images he sent?
** You are now Level 5! **
Yes so much
its printing
can you send the current scripts 🤑
Yea send current script
ok gimme a sec
leaderstats
localscript for the chest to be touched
jumpheight counter in a gui
I said to use :WaitForChild in every variable
how do i use it here then
bcz i dont quite understand it in this script
Show me the output after u touch the chest
** You are now Level 4! **
there is litaraly nothing
Oh
it does touch i think
Put winevent outside of OnPlayerAdded event
Yea
yesir
tysm
Your welcome
just gotta add debounce to it
Will u do it?
yes i know how to do that luckely