CrillicD
(CrillicD)
August 3, 2020, 5:48am
#1
Would really like to work out how to turn this script
into a function that updates the StringValue inside of player PetInventory server side
I can get the my pet to show up client side easily but won’t fire the server to let them know I have the pet.
i’m thinking a remote event since this is held inside a LocalScript inside a Gui
please help
1 Like
Did i understand right, that you nead some way of updating that value with server event?
If i did then its easy, just make script react to event and read values that event is carying and then set up values.
Sorry for broken English…
CrillicD
(CrillicD)
August 3, 2020, 5:55am
#3
you did read it right I need help with how to make a server event inside a local-script that changes the value of the player in server…
im new to server-events can I get a hint where to start the script?
dollychun
(dollychun)
August 3, 2020, 5:56am
#4
There is a tutorial on remote events
1 Like
game.ReplicatedStorage.Revent.OnClientEvent:Connect(function(values)
petVal.Value=values
end)
Change Revent to event name and (values) to what you want
CrillicD
(CrillicD)
August 3, 2020, 6:02am
#6
OnServerEvent not a valid member of folder?
i got bit confused with server event… its client…
CrillicD
(CrillicD)
August 3, 2020, 6:04am
#8
I’ve read into remote events Client > Server before but still not following how to do it with this kind of script.
CrillicD
(CrillicD)
August 3, 2020, 6:05am
#9
still get the same error that its not part of a folder, am I missing a local file
aca1231231
(aca1231231)
August 3, 2020, 6:06am
#10
My English is too poor, i cant explain it…
1 Like
CrillicD
(CrillicD)
August 3, 2020, 6:07am
#11
it was in the right direction though, it felt like it could of worked I’ll keep trying to mess around with your script.
dollychun
(dollychun)
August 3, 2020, 6:07am
#12
You have 2 wrong things
1, you are trying to connect OnServerEvent at folder , change to RemoteEvent.OnServerEvent
2, OnServerEvent:Connect, call it from server script (nomal script), RemoteEvent:FireServer(some value) call from client (localscript).
dollychun
(dollychun)
August 3, 2020, 6:08am
#13
(you have to create RemoteEvent)
aca1231231
(aca1231231)
August 3, 2020, 6:08am
#14
Where did yo put event? It must be in ReplicatedStorage.
RemoteEvent
CrillicD
(CrillicD)
August 3, 2020, 6:09am
#15
but if I put the script inside rep storage I can connect it to a local script?
aca1231231
(aca1231231)
August 3, 2020, 6:13am
#16
I gave you part of local script, i gave you stuff to put in local script, you nead difrent settup for server script service.
aca1231231
(aca1231231)
August 3, 2020, 6:15am
#17
Server funtcions
game.ReplicatedStorage.Revent:FireClient(player,values)
game.ReplicatedStorage.Revent:FireAllClients(values)
game.ReplicatedStorage.Revent.OnServerEvent:Connect(function(player,values)
dollychun
(dollychun)
August 3, 2020, 6:15am
#18
Server code (Script)
local Event = Instance.new("RemoteEvent",game.ReplicatedStorage)
Event.Name = "SomeEvent"
Event.OnServerEvent:Connect(function(Value)
print("Value recived from client:",Value)
end)
Client code (LocalScript):
local Event = game.ReplicatedStorage.SomeEvent
Event:FireServer("This is string send by client")
2 Likes
dollychun
(dollychun)
August 3, 2020, 6:17am
#19
Oops, Server code is wrong
correct one:
local Event = Instance.new("RemoteEvent",game.ReplicatedStorage)
Event.Name = "SomeEvent"
Event.OnServerEvent:Connect(function(Player,Value)
print("Value recived from client, Player:",Player.Name,"Value:",Value)
end)
1 Like
CrillicD
(CrillicD)
August 3, 2020, 6:18am
#20
alright ima sit down and try to edit this thank you for taking your time and writing this out! I’m kind of following what you did and how to proceed hopefully this works