im making a script that spawn a Throne in front of me when i press B, i made a LocalScript to get the key B, it fire an Event that's inside the LocalScript and then a ServerScript get on by the Event, it is inside the event
LocalScript:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
game:GetService("UserInputService").InputBegan:Connect(function(Input, GameProcessed)
if (GameProcessed) then return end
if Input.KeyCode == Enum.KeyCode.B then
script.SpawnThroneEvent:FireServer()
print("Local Script Throne Spawn")
end
end)
ServerScript:
local bool = 0
--local throne = game.ReplicatedStorage:WaitForChild("BaragganThroneRemote")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local hrp = character:WaitForChild("HumanoidRootPart")
local rs = game:GetService("ReplicatedStorage")
local ThroneTest = rs:WaitForChild("ThroneTest")
local model = ThroneTest:Clone()
script.Parent.OnServerEvent:Connect(function(Player)
if Player then
if bool == 0 then
bool = 1
elseif bool == 1 then
bool = 0
end
end
-----------------------------------
while bool == 1 do
model.Parent = game.Workspace
model:PivotTo(hrp.CFrame * CFrame.new(-10, 4, 0))
end
while bool== 0 do
game:GetService("Workspace"):WaitForChild("ThroneTest"):Destroy()
end
end)
LocalScript is working, but the rest no, wt im doing wrong?
