ServerScript Not Working Properly

Alright, I’ll get straight to the point. The server script doesn’t seem to be completing its function and I really need your help.

Working v

Local Script For RemoteEvent

local plr = game.Players.LocalPlayer
local Folder = plr:WaitForChild(“leaderstats”)
local G = script.Parent.Parent.Parent.FinalArea.Gry
local R = script.Parent.Parent.Parent.FinalArea.Rav
local S = script.Parent.Parent.Parent.FinalArea.Sly
local H = script.Parent.Parent.Parent.FinalArea.Huff
local button = script.Parent
local You = script.Parent.Parent.Parent.FinalArea.Title

script.Parent.Activated:Connect(function()
local Oops = math.random(1,4)
if Oops == 1 then
You.Visible = true
G.Visible = true – Gryffindor
R.Visible = false
S.Visible = false
H.Visible = false
game.ReplicatedStorage.Rock:FireServer(“H=1”)
wait(3)
script.Parent.Parent.Parent.Parent.Parent.House.Visible = false
script.Parent.Parent.Parent.Parent.Parent.Main.Visible = true
elseif Oops == 2 then
You.Visible = true
G.Visible = false
R.Visible = true – Ravenclaw
S.Visible = false
H.Visible = false
game.ReplicatedStorage.Rock:FireServer(“H=2”)
wait(3)
script.Parent.Parent.Parent.Parent.Parent.House.Visible = false
script.Parent.Parent.Parent.Parent.Parent.Main.Visible = true
elseif Oops == 3 then
You.Visible = true
G.Visible = false
R.Visible = false
S.Visible = true – Slytherin
H.Visible = false
game.ReplicatedStorage.Rock:FireServer(“H=3”)
wait(3)
script.Parent.Parent.Parent.Parent.Parent.House.Visible = false
script.Parent.Parent.Parent.Parent.Parent.Main.Visible = true
elseif Oops == 4 then
You.Visible = true
G.Visible = false
R.Visible = false
S.Visible = false
H.Visible = true – Hufflepuff
game.ReplicatedStorage.Rock:FireServer(“H=4”)
wait(3)
script.Parent.Parent.Parent.Parent.Parent.House.Visible = false
script.Parent.Parent.Parent.Parent.Parent.Main.Visible = true
end
end)

Not Working v

Server Script To Fulfill Action

local House = game.ReplicatedStorage.Rock

House.OnServerEvent:Connect(function(roger)
if roger == “H=1” then
print(“Gry”)
elseif roger == “H=2” then
print(“Rave”)
elseif roger == “H=3” then
print(“Sly”)
elseif roger == “H=4” then
print(“Huff”)
end
end)

add a player paramater in the server script, should look like

local House = game.ReplicatedStorage.Rock

House.OnServerEvent:Connect(function(player, roger)
if roger == “H=1” then
print(“Gry”)
elseif roger == “H=2” then
print(“Rave”)
elseif roger == “H=3” then
print(“Sly”)
elseif roger == “H=4” then
print(“Huff”)
end
end)

also i suggest you dont post unless you searched the devforum and devhub. the reason for your problem is CLEARLY stated on the remote events and functions page.

2 Likes

First parameter by default is player that fired the remote event. Basically in your script (Roger = Player)