Some info before I start: The AI “JollyMonkey” is inside of ReplicatedStorage, the players model is changed when the player selects their character in the beginning of the game. And the scripts have been HEAVILY altered by ChatGPT (which helped me get some progress but only went so far).
What im aiming to do: When the player presses E, JollyMonkey spawns 2 studs ahead of the players character.
A markdown of the Model and Replicated Storage before and after the game starts:
-ReplicatedStorage
-DominoGR(Player Model)
-Attacks(Folder)
-Script (Server-sided script)
-LocalScript
-Domino
-JollyMonkey(Model)
-CloneAIEvent(RemoteEvent)
and after the player selects the character:
-Workspace
-DominoGR(Parent to everything before)
-ReplicatedStorage(Stays the same)
The scripts:
Server:
local player = game.Players:GetPlayerFromCharacter(script.Parent)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CloneAIEvent = game.ReplicatedStorage.Domino.CloneAIEvent
print("Script Running")
CloneAIEvent.OnServerEvent:Connect(function(player)
print("Connect")
local playerModel = workspace:FindFirstChild(player.Name)
if playerModel then
local humanoid = playerModel:FindFirstChildOfClass("Humanoid")
if humanoid then
local aiClone = game.ReplicatedStorage.Domino.JollyMonkey:Clone()
local offset = Vector3.new(0, 0, 2)
aiClone.Parent = workspace
aiClone:SetPrimaryPartCFrame(humanoid.RootPart.CFrame * CFrame.new(offset))
print("JollyMonkey Cloned")
end
end
end)
LocalScript:
local UserInputService = game:GetService("UserInputService")
local CloneAIEvent = game.ReplicatedStorage.Domino.CloneAIEvent
local key = Enum.KeyCode.E
print("Script Running")
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if not gameProcessed and input.KeyCode == key then
CloneAIEvent:FireServer()
print("Server Fired")
end
end)
When i run the script I dont get any errors at all, but nothing ingame happens. Everything but the last print prints, then it just stops. No monkey gets cloned, nothing.
