generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Why aren't my "Changed" events firing?

Previous Thread :: Next Thread 
Spathi is not online. Spathi
Joined: 18 Nov 2013
Total Posts: 14776
23 May 2017 04:27 PM
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function()
local LoadOutUI = game.ReplicatedStorage.LoadOutUI:Clone()
LoadOutUI.Parent = Player.PlayerGui

--Melee Weapons
if game.ServerStorage.PlayerData[Player.Name].Stats.OwnsPlank.Value == true then
game.ReplicatedStorage.Events.OwnsPlank:FireClient(Player)
wait(.1)
end

if game.ServerStorage.PlayerData[Player.Name].Stats.OwnsPipe.Value == true then
game.ReplicatedStorage.Events.OwnsPipe:FireClient(Player)
wait(.1)
end

if game.ServerStorage.PlayerData[Player.Name].Stats.OwnsBat.Value == true then
game.ReplicatedStorage.Events.OwnsBat:FireClient(Player)
wait(.1)
end

if game.ServerStorage.PlayerData[Player.Name].Stats.OwnsMachete.Value == true then
game.ReplicatedStorage.Events.OwnsMachete:FireClient(Player)
wait(.1)
end

if game.ServerStorage.PlayerData[Player.Name].Stats.OwnsAxe.Value == true then
game.ReplicatedStorage.Events.OwnsAxe:FireClient(Player)
wait(.1)
end

--GasMask
if game.ServerStorage.PlayerData[Player.Name].Stats.OwnsGasMask.Value == true then
game.ReplicatedStorage.Events.OwnsGasMask:FireClient(Player)
wait(.1)
end

game.ReplicatedStorage.Events.BagOpen.OnServerEvent:Connect(function(Player)
game.ReplicatedStorage.Events.VisibleLoadOut:FireClient(Player)

--MeleeWeapons
--Plank

LoadOutUI.LoadOut.Changed:Connect(function()
--Owns Plank
if game.ServerStorage.PlayerData[Player.name].Stats.OwnsPlank.Value == true then
game.ReplicatedStorage.Events.OwnsPlank:FireClient(Player)
end
end)

LoadOutUI.LoadOut.Changed:Connect(function()
wait(.1)
--Owns Pipe
if game.ServerStorage.PlayerData[Player.name].Stats.OwnsPipe.Value == true then
game.ReplicatedStorage.Events.OwnsPipe:FireClient(Player)
end
end)
wait(.1)

LoadOutUI.LoadOut.Changed:Connect(function()
--Owns Bat
if game.ServerStorage.PlayerData[Player.name].Stats.OwnsBat.Value == true then
game.ReplicatedStorage.Events.OwnsBat:FireClient(Player)
end
end)
wait(.1)

LoadOutUI.LoadOut.Changed:Connect(function()
--Owns Machete
if game.ServerStorage.PlayerData[Player.name].Stats.OwnsMachete.Value == true then
game.ReplicatedStorage.Events.OwnsMachete:FireClient(Player)
end
end)
wait(.1)

--Owns Axe
LoadOutUI.LoadOut.Changed:Connect(function()
if game.ServerStorage.PlayerData[Player.name].Stats.OwnsAxe.Value == true then
game.ReplicatedStorage.Events.OwnsAxe:FireClient(Player)
end
end)

wait(.1)
--Owns GasMask
LoadOutUI.LoadOut.Changed:Connect(function()
if game.ServerStorage.PlayerData[Player.name].Stats.OwnsGasMask.Value == true then
game.ReplicatedStorage.Events.OwnsGasMask:FireClient(Player)
end
end)
end)
end)
end)


Report Abuse
GNUnotUNIX is not online. GNUnotUNIX
Joined: 05 Feb 2012
Total Posts: 15171
23 May 2017 04:35 PM
TL;DR
Report Abuse
Spathi is not online. Spathi
Joined: 18 Nov 2013
Total Posts: 14776
23 May 2017 04:37 PM
I thought someone would say that. Sorry, I know it's a lot lmao


Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
23 May 2017 04:38 PM
dont do that just use a remote function on the client to get which tools are equipped

and then use a remote event to equip it, having the server check if they actually have it
Report Abuse
Spathi is not online. Spathi
Joined: 18 Nov 2013
Total Posts: 14776
23 May 2017 04:39 PM
This is a server script

There's a local script that goes along with this


game.ReplicatedStorage.Events.VisibleLoadOut.OnClientEvent:Connect(function()
script.Parent.LoadOut.Visible = true

--Melee Weapons
--Plank
game.ReplicatedStorage.Events.OwnsPlank.OnClientEvent:Connect(function()
if script.Parent.LoadOut.MeleeWeapons.Plank.Equipped.Value == false then
wait(.1)
script.Parent.LoadOut.MeleeWeapons.Plank.Visible = true
end

--Pipe
game.ReplicatedStorage.Events.OwnsPipe.OnClientEvent:Connect(function()
if script.Parent.LoadOut.MeleeWeapons.Pipe.Equipped.Value == false then
wait(.1)
script.Parent.LoadOut.MeleeWeapons.Pipe.Visible = true
end

--Bat
game.ReplicatedStorage.Events.OwnsBat.OnClientEvent:Connect(function()
if script.Parent.LoadOut.MeleeWeapons.Bat.Equipped.Value == false then
wait(.1)
script.Parent.LoadOut.MeleeWeapons.Bat.Visible = true
end

--Machete
game.ReplicatedStorage.Events.OwnsMachete.OnClientEvent:Connect(function()
if script.Parent.LoadOut.MeleeWeapons.Machete.Equipped.Value == false then
wait(.1)
script.Parent.LoadOut.MeleeWeapons.Machete.Visible = true
end

--Axe
game.ReplicatedStorage.Events.OwnsAxe.OnClientEvent:Connect(function()
if script.Parent.LoadOut.MeleeWeapons.Axe.Equipped.Value == false then
wait(.1)
script.Parent.LoadOut.MeleeWeapons.Axe.Visible = true
end

--GasMask
game.ReplicatedStorage.Events.OwnsGasMask.OnClientEvent:Connect(function()
wait(.1)
script.Parent.LoadOut.GasMaskEquip.Visible = true
end)
end)
end)
end)
end)
end)
end)


Report Abuse
Spathi is not online. Spathi
Joined: 18 Nov 2013
Total Posts: 14776
23 May 2017 04:40 PM
Let me make myself clear, the one first posted is a server script

the second one is local


Report Abuse
Spathi is not online. Spathi
Joined: 18 Nov 2013
Total Posts: 14776
23 May 2017 04:40 PM
it was working just fine until I added the gas mask, I messed it all up


Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
23 May 2017 04:41 PM
something like this

local data = {}
data[player] = {Owns = {gasmask=true,blah=true}}

owns.OnClientInvoke = function( player )
return data[player].Owns --then make visible on gui
end

loadoutPressed.OnServerEvent:connect(function( player, request)
if data[player].Owns[request] then
--change loadout value
end
end)
Report Abuse
Spathi is not online. Spathi
Joined: 18 Nov 2013
Total Posts: 14776
23 May 2017 04:43 PM
This worked just fine until I added the gas mask stuff


Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
23 May 2017 04:47 PM
ik but that is a horrible way to do it
look how mine makes more sense xd
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
23 May 2017 04:49 PM
this way u ask server when u want to know what u own and check if they have what they r trying to select without having to make like 10 remote events for each item
Report Abuse
Spathi is not online. Spathi
Joined: 18 Nov 2013
Total Posts: 14776
23 May 2017 04:55 PM
Dude

Not everyone is as good as a coder as you, we all have to start somewhere. And this is my first project all by myself, there's no hell in way that I'm gonna learn without making things, code efficiency will come with time


Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
23 May 2017 04:56 PM
u should start off making things more efficient when u learn about them or else its too late lol
just do it this way as it makes more sense in the long run than having to re-adjust ur code every time u add in a new item
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
23 May 2017 04:58 PM
when u add in a new item the rest should be automatic because u would create the display of items based on how many items there are and u would make the tools load in based on what they own
then the only thing left to add or change are effects and price instead of modifying other scripts just so that it works for that specific item
Report Abuse
Spathi is not online. Spathi
Joined: 18 Nov 2013
Total Posts: 14776
23 May 2017 04:58 PM
When I've had the time to learn, I'll come back to it. But for now, this is the best of my ability


Report Abuse
Spathi is not online. Spathi
Joined: 18 Nov 2013
Total Posts: 14776
23 May 2017 05:01 PM
May I add, it works perfectly without FE, but with FE it breaks


Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
23 May 2017 05:06 PM
its not hard heres a simple example

local session = {}
game.Players.PlayerAdded:connect(function(player)
--load data
--should be like this
--[[
{
Items = {
gasmask = true;
thing = true;
};
Equipped = {};
}
you can make other tool names set to false too, but unnecessary
]]--
session[player] = data
end)

--buying will be done with a remote function, not sure how u want to do that so leaving it out
--but after u buy just set data[player].Items[itemName] = true

getItems.OnServerInvoke = function( player ) return session[player] end --so they dont directly have access to the items
--on the client, can iterate with
--[[
local tbl = next,getItems:InvokeServer()
for item in tbl.Items do print(item,tbl.Equipped[item]) end
]]--
equipItem.OnServerInvoke = function(player,item,t) --t used for unequipping (false) or equipping (true)
if session[player][item] then
--equip item on the server
session[player].Equipped[item] = t
--can unequip other items if needed
return true --let client know
end
return false --does not own the item, can be used to show a gui
end

game.Players.PlayerRemoving:connect(function(player)
--save data in the similar format or just save session[player] since u can modify the original data
end)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image