hello everyone
i am working on a zombie game based on Apocalypse Rising 1
and i have made pages scattered around the map to add some lore
i also have a script inside the StoryGui that checks if any frame got clicked if it has been clicked then it closes
it also doesent fire any error.
here is the script that opens the page
this is a ServerScript
local Paper = script.Parent
Paper.ProximityPrompt.Triggered:Connect(function(playerWhoTriggered)
playerWhoTriggered.PlayerGui:FindFirstChild("StoryGui"):FindFirstChild(Paper.Name).Visible = true
playerWhoTriggered.Character:FindFirstChildWhichIsA("Humanoid").WalkSpeed = 0
end)
here is the script that closes the page
this is a ClientScript
local StoryFolder = workspace.StoryFolder
local Player = game.Players.LocalPlayer
local Gui = script.Parent
for _, i in pairs(Gui:GetChildren()) do
if i:IsA("ImageButton") then
i:GetPropertyChangedSignal("Visible"):Connect(function()
Gui.PaperSound:Play()
end)
i.MouseButton1Click:Connect(function()
Gui.PaperSound:Play()
i.Visible = false
Gui.ChangeWalkSpeedEvent:FireServer()
end)
end
end
sorry for my bad english it isint my first laungauge.
So is the issue that after the first time they interact with a page (activate the proximity prompt and then click on the page to close it) then the next time they interact with that same page it isn’t visible?
Have you tried putting a print statement or a debug breakpoint in the server script that’s trying to set visible = true to make sure it’s getting triggered the second time?
And is the hierarchy of your GUI just something like:
Ok, I setup a sample test and confirmed that there is weird behavior in the replication of the PlayerGui from server to client. I kind of surprised changing the visibility on the server side works the first time.
What I would switch to is for the server to fire a RemoteEvent to that player, that the Client script is listening for.
Something like game.ReplicatedStorage.Remotes.ShowPage:FireClient(PlayerWhoTriggered, Paper.Name)
This whole method is not made very well. You could utilize RemoteEvents to simply put it all on the client side instead of setting the gui visibility on the server. Heres an example ServerScript:
local Paper = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PaperEvent = ReplicatedStorage:FindFirstChild("PaperPickup")
Paper.ProximityPrompt.Triggered:Connect(function(playerWhoTriggered)
PaperEvent:FireClient()
playerWhoTriggered.Character:FindFirstChildWhichIsA("Humanoid").WalkSpeed = 0
end)
And the localscript:
local StoryFolder = workspace.StoryFolder
local Player = game.Players.LocalPlayer
local Gui = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PaperEvent = ReplicatedStorage:FindFirstChild("PaperPickup")
PaperEvent.OnClientEvent:Connect(function()
Gui.Visible = true
Gui.PaperSound:Play()
for _, i in pairs(Gui:GetChildren()) do
i.MouseButton1Click:Connect(function()
Gui.PaperSound:Play()
i.Visible = false
Gui.ChangeWalkSpeedEvent:FireServer() -- This is seperate from what I'm helping you with, although you dont pass any data for who the walkspeed should be changed for.
end)
end
end)