So I am following Alvin_Blox’s tutorial about the mining simulator shop. But, there is an issue. The issue is in the part where when the player resets the camera goes back to the player and the shop is not enabled. But as you can see in the GIF it doesn’t work. I have been trying to find a fix like for 2 days now so please help.
Here is the script:
local player = game.Players.LocalPlayer
local replicatedStorage = game:GetService(“ReplicatedStorage”)
local shopFrame = script.Parent:WaitForChild(“ShopFrame”)
local camera = game.Workspace.CurrentCamera
ReplicatedStorage.PlayerReset.OnClientEvent:Connect(function() — this function happens whenever the player dies.
shopFrame.Visible = false
camera.CameraType = “Custom”
camera.CameraSubject = player.Character:WaitForChild(“Humanoid”)
player.inShop.Value = false
end)
local player = game.Players.LocalPlayer
local replicatedStorage = game:GetService(“ReplicatedStorage”)
local shopFrame = script.Parent:WaitForChild(“ShopFrame”)
local camera = game.Workspace.CurrentCamera
ReplicatedStorage.PlayerReset.OnClientEvent:Connect(function() --this function happens whenever the player dies.
shopFrame.Visible = false
camera.CameraType = Enum.CameraType.Custom
player.inShop.Value = false
end)
local player = game.Players.LocalPlayer
local replicatedStorage = game:GetService(“ReplicatedStorage”)
local shopFrame = script.Parent:WaitForChild(“ShopFrame”)
local camera = game.Workspace.CurrentCamera
ReplicatedStorage.PlayerReset.OnClientEvent:Connect(function() --this function happens whenever the player dies.
shopFrame.Visible = false
camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = player.Character:WaitForChild(“Humanoid”)
player.inShop.Value = false
end)
Well that’s the problem, your firing the remote when the player joins. Your not detecting it when the player resets. Do this instead:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
while wait() do
character:WaitForChild("Humanoid").Died:Connect(function()
game.ReplicatedStorage.PlayerReset:FireClient(player)
end)
end
end)
end)
try this.
wait(5)
local player = game.Players.LocalPlayer
local replicatedStorage = game:GetService(“ReplicatedStorage”)
local shopFrame = script.Parent:WaitForChild(“ShopFrame”)
local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local replicatedStorage = game:GetService(“ReplicatedStorage”)
local shopFrame = script.Parent:WaitForChild(“ShopFrame”)
local camera = game.Workspace.CurrentCamera
ReplicatedStorage.PlayerReset.OnClientEvent:Connect(function() --this function happens whenever the player dies.