Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What function would I use to access a value from another player?

Asked by
BloxRoxe 109
6 years ago
Edited 6 years ago

I have a button that allows you to challenge a player that you want to play against. Everything works fine, but I want to add a function where if the player you want to battle already has a request from someone else, the RequestRemote wont fire and give the player an error message. I just don't know what function can accomplish this because the Boolean value has to be accessed from the localscript.

The boolean "hasRequest" is created in everyone's Player. This is the value I want to check before sending a request.

Here is my LocalScript for reference:

01local id = script.Parent.Parent:WaitForChild("PlayerID")
02local text = script.Parent:WaitForChild("Battletext")
03local Request = game.ReplicatedStorage.DefaultRequest
04local localgui = game:GetService('Players').LocalPlayer:WaitForChild("PlayerGui")
05local localplayerid = game.Players.LocalPlayer.UserId
06local lookfor = game.ReplicatedStorage.BattleEvent
07local lookForGameNextClick = true
08local player = game:GetService("Players"):GetPlayerByUserId(id.Value)
09local localname = game.Players.LocalPlayer.Name
10local iswaiting = game:GetService('Players').LocalPlayer:WaitForChild("WaitingForPlayer")
11local hasgui = game:GetService('Players').LocalPlayer:WaitForChild("hasRequest")
12 
13 
14 
15script.Parent.MouseButton1Click:connect(function()
View all 58 lines...

ServerScript

01local changeRemote = Instance.new("RemoteEvent", game.ReplicatedStorage)
02changeRemote.Name = "BoolTrueRemote"
03 
04local change2Remote = Instance.new("RemoteEvent", game.ReplicatedStorage)
05change2Remote.Name = "BoolFalseRemote"
06 
07local declineRemote = Instance.new("RemoteEvent", game.ReplicatedStorage)
08declineRemote.Name = "DeclineRemote"
09 
10local Decline = game.ReplicatedStorage.defaultDecline
11 
12local requestRemote = Instance.new("RemoteEvent", game.ReplicatedStorage)
13requestRemote.Name = "RequestRemote"
14 
15local Request = game.ReplicatedStorage.DefaultRequest
View all 92 lines...
0
Please post the server script code. User#19524 175 — 6y
0
Okay BloxRoxe 109 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

Clone a local script to the player that they are trying to request to battle with and check if they are battling or have a current request. Then fire a remote event to communicate with the server and then communicate back to the player sending the request.

0
Alright, I think I know what to do now. BloxRoxe 109 — 6y
Ad

Answer this question