Help fixing problem that I have with Alvin_Blox mining simulator shop

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.

image

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)

1 Like

Do this instead:

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)

I think this should work.

2 Likes

Alright, so I did it. But, it did the same thing.

You should set up an event where if the character dies, you reset their camera focusing to the humanoid of the camera.

So like this then?

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)

Test it and see if it works. Not sure.

I just tried this and it did the same thing…

What is your server script? Maybe it’s the server script problem?

It’s a local script in StarterGui.

Yeah I mean can you give the server script that fires the remote event?

Yea here:

game.Players.PlayerAdded:Connect(function(player)

          game.ReplicatedStorage.PlayerReset:FireClient(player)
   end

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)
1 Like

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

ReplicatedStorage.PlayerReset.OnClientEvent:Connect(function()

    shopFrame.Visible = false
    camera.CameraType = Enum.CameraType.Custom
    player.inShop.Value = false

end)

The problem is the server script. The script just fires it when a player joins, not detect when a player reset character.

Use the character added function instead of polling as others suggested.

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        --fire remote event
    end)
end)
1 Like

if you really want that to not be an issue i guess you could disable resetting completely (unless you need it for your game)

It works, but this happens.
image

Can I see the local script again?

Yea

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 the only thing that I could think of is that the HumanoidRootPart touched the shop for a second.